Results 1 to 2 of 2

Thread: mc_teo's Nooby PowerMiner

  1. #1
    Join Date
    Mar 2009
    Location
    Ireland
    Posts
    111
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default mc_teo's Nooby PowerMiner

    Hello, this is my first release of my powerminer

    this was my first script, and it works, so i was just looking for ways to improve it

    any comments/suggestions welcome...

  2. #2
    Join Date
    Oct 2007
    Location
    Denmark
    Posts
    409
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quite good for your first script.

    Here comes the critique

    First of all, look into the Mining include. It has some Rockfinding functions and Pickaxe finding.

    SCAR Code:
    {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~)
    (     Name := mc_teo's PowerMiner                    )
    (     Author := mc_teo                               )
    (     SCAR Ver := 3.15b                              )
    (     SRL Rev := #31                                 )
    (     Comments :=                                    )
    (         AutoColoring isnt the best,                )
    (           but unless you can do it,                )
    (           there's no point complaining             )
    (                                                    )
    (      SetUp := 1.) select 'form_load' on or off     )
    (                     (recommended on)               )
    (               2.) Goto a mine!                     )
    (               3.) Drag Crosshairs to game window   )
    (               4.) Click Play                       )
    (               5.) Happy botting                    )
    (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}


    program my_power_miner;
    {.include SRL\SRL.scar}
    {.include SRL\SRL\skill\Mining.scar}

    const
      nore = 10000;
      rockwait = 6000;
      form_load = true;
      Copper_ore = 4225488;
      Tin_ore = 8027016;
      Iron_ore = 2371405;
      Silver_ore = 7442074;
      Coal_ore = 1977645;
      Gold_ore = 1093081;

    var

      x, y, mined:integer;
      num_ore, num_loads:integer;
      pickaxe_equiped:boolean;
      main_ore, second_ore, Username, Password :string;
      main_ore_color, second_ore_color:integer;
      frmDesign : TForm;
      Label1 : TLabel;
      Label2 : TLabel;
      Label3 : TLabel;
      Label4 : TLabel;
      Label5 : TLabel;
      Label6 : TLabel;
      Button1 : TButton;
      Button2 : TButton;
      Edit1 : TEdit;
      Edit2 : TEdit;
      ComboBox1 : TComboBox;
      ComboBox2 : TComboBox;
      ComboBox3 : TComboBox;

    procedure exit_click(sender: TObject);
    begin
      frmDesign.ModalResult:= mrOk;
      TerminateScript;
    end;

    procedure save_click(sender: TObject);
    begin
      main_ore := ComboBox1.Text;
      second_ore := ComboBox2.Text;
      Username := Edit1.Text;
      Password := Edit2.Text;
      if(Combobox3.text = 'true') then
        begin
        pickaxe_equiped := true;
        end
      else
        begin
        pickaxe_equiped := false;
        end;
      frmDesign.ModalResult:= mrOk;
    end;

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name := Username;
      Players[0].Pass := Password;
      Players[0].Loc := 'Mine';
      Players[0].Active := True;

      {Players[1].Name := Edit1.Text;
      Players[1].Pass := Edit2.Text;
      Players[1].Loc := 'Mine';
      Players[1].Active := True;

      Players[2].Name := Edit9.Text;
      Players[2].Pass := Edit10.Text;
      Players[2].Nick := Edit11.Text;
      Players[2].Loc := 'Mine';
      Players[2].Active := CheckBox6.Checked;

      Players[3].Name := Edit13.Text;
      Players[3].Pass := Edit14.Text;
      Players[3].Nick := Edit15.Text;
      Players[3].Loc := 'Mine';
      Players[3].Active := CheckBox8.Checked;

      Players[4].Name := Edit17.Text;
      Players[4].Pass := Edit18.Text;
      Players[4].Nick := Edit19.Text;
      Players[4].Loc := 'Mine';
      Players[4].Active := CheckBox10.Checked;}

    end;

    procedure InitForm;
    begin
    frmDesign := CreateForm;
    frmDesign.Left := 325;
    frmDesign.Top := 130;
    frmDesign.Width := 366;
    frmDesign.Height := 296;
    frmDesign.Caption := 'mc_teo'#39's PowerMiner';
    frmDesign.Color := clBtnFace;
    frmDesign.Font.Color := clWindowText;
    frmDesign.Font.Height := -11;
    frmDesign.Font.Name := 'MS Sans Serif';
    frmDesign.Font.Style := [];
    frmDesign.Visible := False;
    frmDesign.PixelsPerInch := 96;
    Label1 := TLabel.Create(frmDesign);
    Label1.Parent := frmDesign;
    Label1.Left := 64;
    Label1.Top := 56;
    Label1.Width := 48;
    Label1.Height := 13;
    Label1.Caption := 'Username';
    Label2 := TLabel.Create(frmDesign);
    Label2.Parent := frmDesign;
    Label2.Left := 64;
    Label2.Top := 88;
    Label2.Width := 46;
    Label2.Height := 13;
    Label2.Caption := 'Password';
    Label3 := TLabel.Create(frmDesign);
    Label3.Parent := frmDesign;
    Label3.Left := 8;
    Label3.Top := 8;
    Label3.Width := 329;
    Label3.Height := 29;
    Label3.Caption := 'mc_teo'#39's Noobish PowerMiner';
    Label3.Font.Color := clWindowText;
    Label3.Font.Height := -24;
    Label3.Font.Name := 'MS Sans Serif';
    Label3.Font.Style := [];
    Label3.ParentFont := False;
    Label4 := TLabel.Create(frmDesign);
    Label4.Parent := frmDesign;
    Label4.Left := 64;
    Label4.Top := 120;
    Label4.Width := 43;
    Label4.Height := 13;
    Label4.Caption := 'Main Ore';
    Label5 := TLabel.Create(frmDesign);
    Label5.Parent := frmDesign;
    Label5.Left := 64;
    Label5.Top := 152;
    Label5.Width := 71;
    Label5.Height := 13;
    Label5.Caption := 'Secondary Ore';
    Label6 := TLabel.Create(frmDesign);
    Label6.Parent := frmDesign;
    Label6.Left := 64;
    Label6.Top := 184;
    Label6.Width := 80;
    Label6.Height := 13;
    Label6.Caption := 'Pickaxe Equiped';
    Button1 := TButton.Create(frmDesign);
    Button1.Parent := frmDesign;
    Button1.OnClick := @save_click;
    Button1.Left := 64;
    Button1.Top := 224;
    Button1.Width := 97;
    Button1.Height := 25;
    Button1.Caption := 'Save';
    Button1.TabOrder := 8;
    Button2 := TButton.Create(frmDesign);
    Button2.Parent := frmDesign;
    Button2.OnClick := @exit_click;
    Button2.Left := 176;
    Button2.Top := 224;
    Button2.Width := 97;
    Button2.Height := 25;
    Button2.Caption := 'Exit';
    Button2.TabOrder := 9;
    ComboBox1 := TComboBox.Create(frmDesign);
    ComboBox1.Parent := frmDesign;
    ComboBox1.Left := 160;
    ComboBox1.Top := 120;
    ComboBox1.Width := 113;
    ComboBox1.Height := 21;
    ComboBox1.ItemHeight := 13;
    ComboBox1.ParentShowHint := False;
    ComboBox1.ShowHint := False;
    ComboBox1.TabOrder := 10;
    ComboBox1.Items.Add('Copper');
    ComboBox1.Items.Add('Tin');
    ComboBox1.Items.Add('Iron');
    ComboBox1.Items.Add('Silver');
    ComboBox1.Items.Add('Coal');
    ComboBox1.Items.Add('Gold');
    Edit1 := TEdit.Create(frmDesign);
    Edit1.Parent := frmDesign;
    Edit1.Left := 160;
    Edit1.Top := 56;
    Edit1.Width := 113;
    Edit1.Height := 21;
    Edit1.TabOrder := 11;
    Edit2 := TEdit.Create(frmDesign);
    Edit2.Parent := frmDesign;
    Edit2.Left := 160;
    Edit2.Top := 88;
    Edit2.Width := 113;
    Edit2.Height := 21;
    Edit2.TabOrder := 12;
    Edit2.PasswordChar := '*';
    ComboBox2 := TComboBox.Create(frmDesign);
    ComboBox2.Parent := frmDesign;
    ComboBox2.Left := 160;
    ComboBox2.Top := 152;
    ComboBox2.Width := 113;
    ComboBox2.Height := 21;
    ComboBox2.ItemHeight := 13;
    ComboBox2.TabOrder := 13;
    ComboBox2.Items.Add('Copper');
    ComboBox2.Items.Add('Tin');
    ComboBox2.Items.Add('Iron');
    ComboBox2.Items.Add('Silver');
    ComboBox2.Items.Add('Coal');
    ComboBox2.Items.Add('Gold');
    ComboBox3 := TComboBox.Create(frmDesign);
    ComboBox3.Parent := frmDesign;
    ComboBox3.Left := 160;
    ComboBox3.Top := 184;
    ComboBox3.Width := 113;
    ComboBox3.Height := 21;
    ComboBox3.ItemHeight := 13;
    ComboBox3.TabOrder := 14;
    ComboBox3.Items.Add('False');
    ComboBox3.Items.Add('True');
    ComboBox3.Text := 'False';
    end;

    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

    procedure SafeShowFormModal;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('ShowFormModal', v);
    end;

    Procedure Pick_Ore;
    Begin
      case main_ore of
        'Copper': main_ore_color := Copper_ore;
        'Tin': main_ore_color := Tin_ore;
        'Iron': main_ore_color := Iron_ore;
        'Silver': main_ore_color := Silver_ore;
        'Coal': main_ore_color := Coal_ore;
        'Gold': main_ore_color := Gold_ore;
      end;
      case second_ore of
        'Copper': second_ore_color := Copper_ore;
        'Tin': second_ore_color := Tin_ore;
        'Iron': second_ore_color := Iron_ore;
        'Silver': second_ore_color := Silver_ore;
        'Coal': second_ore_color := Coal_ore;
        'Gold': second_ore_color := Gold_ore;
      end;
    End;

    Procedure Progress;
    Begin
      ClearDebug;
      WriteLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
      WriteLn('You have been using auto miner by mc_teo');
      WriteLn('Script Ran for ' + TimeRunning);
      WriteLn('Total Ore Found is ' + IntToStr(num_ore));
      WriteLn('Total Loads Dropped is ' + IntToStr(num_loads));
      WriteLn('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
    end;

    procedure Miner;
    begin
      repeat
        if (not(LoggedIn)) then
          LoginPlayer;
        if FindColorSpiralTolerance(x, y, main_ore_color, MSx1, MSy1, MSx2, MSy2, 5) or // Notice the OR
           FindColorSpiralTolerance(x, y, second_ore_color, MSx1, MSy1, MSx2, MSy2, 5) then
        begin
          Inc(num_ore);
          case Random(2) of
            0: Mouse(x, y, 5, 5, True);
            1:
            begin
              Mouse(x, y, 5, 5, False);
              Wait(500 + Random(200));
              ChooseOption('ine');
            end;
          end;
          Inc(mined); // Inc instead of + 1. You could look into Dtms and make it count the items. Functions you could use: InvBox, FindDTM
          Wait(rockwait + Random(500));
        end;
        Progress;
      until(InvFull or (mined > 50));
    end;

    procedure Drop; // Trimmed the procedure. Please look into what has been done.
    var
      I, c: integer;
    begin
      case pickaxe_equiped of
        True: c := 1;
        False: c := 2;
      end
      if InvFull or (mined > 50) then
      begin
        for I := c to 28 do
          DropItem(I);
        Inc(num_loads); // Use increase instead of + 1
      end;
    end;

    begin
      SetupSRL;
      if form_load then // no need for = true
      begin
        SafeInitForm;
        SafeShowFormModal;
      end;
      DeclarePlayers;
      ActivateClient;
      repeat
        if not LoggedIn then
          LoginPlayer; //helps, and fail safes
        Progress;
        Miner;
        Drop;
      until(mined = nore); //now it stops when you mined your specified amount of ore
    end.

    Added some comments

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •