SRL Archive - First Scripts

Nooby AutoMiner


mc_teo

2009-03-28 19:33:28

This is my first script.

Just made it because I was board doing it manually.

It started off as just clicking the middle of the screen, and then i added a custom drop second item in inventory.

then i added more functions as i read more tutorials.

So can i have some feedback please…..

All comments/feedback welcome…

JPHamlett

2009-03-28 20:37:20

how about u attach the file

Awkwardsaw

2009-03-28 21:48:15

for a beginner, it looks really good. there was one error, but that as just a little mistake:

at the declare players where you bracketed it out, you missed the end; , so it said "begin expected in script"

you should also add in failsafes and antiban

and, here is the script somewhat fixed up, ith comments telling you what i fixed, and why

{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~)
( 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 = 100; //number of ore you ish to mine, used for a fail safe
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; //added mined as an integer for a counter, self explanitory
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;
end;

procedure save_click(sender: TObject);
begin
ComboBox1.Text := main_ore;
ComboBox2.Text := second_ore;
Username := Edit1.Text; //so the form actually does something
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; //it now logs you on
begin
HowManyPlayers := 1; //Number of players
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].Boolean1 := CheckBox5.Checked;
Players[2].String1 := Player3Ore;
Players[2].String2 := Edit12.Text;
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].Boolean1 := CheckBox7.Checked;
Players[3].String1 := Player4Ore;
Players[3].String2 := Edit16.Text;
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].Boolean1 := CheckBox9.Checked;
Players[4].String1 := Player5Ore;
Players[4].String2 := Edit20.Text;
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.DropDownCount := 4;
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('True');
ComboBox3.Items.Add('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; //you had nothing here, so if you wherent logged on, it would mine, and if you where, it would not
if FindColorSpiralTolerance(x, y, main_ore_color, MSx1, MSy1, MSx2, MSy2, 5) then
begin
num_ore := num_ore + 1;
Mouse(x, y, 5, 5, true);
mined := mined + 1; //added an other counter, i know i didnt have to, but why not =p
Wait(rockwait + Random(500));
end

else if FindColorSpiralTolerance(x, y, second_ore_color, MSx1, MSy1, MSx2, MSy2, 5) then
begin
num_ore := num_ore + 1;
Mouse(x, y, 5, 5, true);
mined := mined + 1; //same as above
Wait(rockwait + Random(500));
end;
Progress;
until(InvFull or (mined > 50)); //added a fail safe, so if it doesnt get the ore in 50 tries, it stops and moves on
end;

procedure Drop;
var
I: integer;
begin
if (InvFull or (mined > 50)) then
begin
for I := 1 to 28 do DropItem(I); //it dropped items up to the 12th spot, now it does every thing
num_loads := num_loads + 1;
end;
end;

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

i know you probobly have the stuff bracketed out for a reason, but i changed it to what i would do, feel free to change it again if you want(its your script after all =p)

no need to credit me or + rep

mc_teo

2009-04-08 07:45:12

I attached the file

da scripter

2009-04-16 04:44:27

Looks like a good script, you should focus more on basic procedures and main loop instead of things like a form. Gr8 Script for beginner though.

Raskolnikov

2009-04-19 22:57:39

This is very good for a beginner. I would work on some of your standards on the forms. You need to spend more time on the main procedures, other than doing a form or cosmetic addons. You have a very good script, but it has room for improvement, learning TPointArrays, DTMs for pickaxes, etc.

If you have questions about standards, look at the link in my signature.

Good luck,
Cutem2it

Kryptic

2009-04-20 00:13:13

From: Cut em2 it
This is very good for a beginner. I would work on some of your standards on the forms. You need to spend more time on the main procedures, other than doing a form or cosmetic addons. You have a very good script, but it has room for improvement, learning TPointArrays, DTMs for pickaxes, etc.

If you have questions about standards, look at the link in my signature.

Good luck,
Cutem2it


I Agree!!!! :D

~Kryptic

Smarter Child

2009-04-20 03:42:47

For a first script, it is pretty well done. Like previous have said, some more DTM's/Bitmaps or TPointArray's and standards, would make that script an A+.

mc_teo

2009-04-23 20:35:36

Thanks for all comments…

I've come along abit since then, including hugely in my scripting, using TPAs, and bitmaps… (I still dont really understand the usefulness of DTMs, and DDTMs)

I dont realease as much as I would like, because I dislike added all the failsafes and anti-randoms, etc, needed for it to actually be a useful release…

I watch the server i run scar on, conatantly, so i've never had need for anti-randoms.

I guess I should, esp with my members script…

Ive made an auto-Thiefer, a Cow-Hide Banker, a flax picker-spinner-banker, really anything that i find useful…

so anyways, thanks for the comments and the feedback, and I will update this script soon, hopefully…

Dynamite

2009-04-28 21:37:22

Good script, if you arent going to add failsafes, anti ban, anti randoms, then only a few will actually use this script (more advanced maybe) but if you added them things, then this would be a very strong script for your first script and think about putting a new and huge update in Free for all or Jnr Members
PM me if you need a tester ;)

T~M

marpis

2009-04-28 22:22:35

There is no place to enter player nick?
If this is your first script, wow.
Just make a rock finding function with TPA's, use DTM's to find ores in inventory and it's very usable! Their not hard at all to understand.

Now your mining procedure might click some other object that just happens to have the same color with rocks. Make it go like

procedure Miner;
begin
if not loggedin then exit; //added this
repeat
if FindColorSpiralTolerance(x, y, main_ore_color, MSx1, MSy1, MSx2, MSy2, 5) then
begin
MMouse(x, y, 3, 3);
wait(100+random(100));
If IsUpText('ine') then //find Mine text in the upper left corner
begin
num_ore := num_ore + 1;
GetMousePos(x, y); //save the mouse position to x and y
Mouse(x, y, 0, 0, true); //this is to prevent botlike mousemovement
Wait(rockwait + Random(500));
end;
end
else if FindColorSpiralTolerance(x, y, second_ore_color, MSx1, MSy1, MSx2, MSy2, 5) then
begin
MMouse(x, y, 3, 3);
wait(100+random(100));
If IsUpText('ine') then //find Mine text in the upper left corner
begin
num_ore := num_ore + 1;
GetMousePos(x, y); //save the mouse position to x and y
Mouse(x, y, 0, 0, true); //this is to prevent botlike mousemovement
Wait(rockwait + Random(500));
end;
end
Progress;
until(InvFull)
end;

this could be done even shorter way.
to understand this, recall what
- for i := 0 to (?) do
- arrays
mean

procedure Miner;
var
colours: TIntegerArray;
begin
if not loggedin then exit;
colours:= [main_ore_color, second_ore_color];
repeat
for i:= 0 to 1 do
if FindColorSpiralTolerance(x, y, colours[i], MSx1, MSy1, MSx2, MSy2, 5) then
begin
MMouse(x, y, 3, 3);
wait(100+random(100));
If IsUpText('ine') then //find Mine text in the upper left corner
begin
num_ore := num_ore + 1;
GetMousePos(x, y); //save the mouse position to x and y
Mouse(x, y, 0, 0, true); //this is to prevent botlike mousemovement
Wait(rockwait + Random(500));
exit;
end;
end else Inc(fails);
until(fails > 4);
end;

EDIT: noes, i replied to a month-old thread! again!

sk8terbitu

2009-04-29 17:19:34

wow for a first script, Pascal programmer much???

Rasta

2009-04-29 17:40:30

Not too shabby!! this is really good for a first script and i'll have to test it out later on when I have a chance

scar_ownz

2009-05-02 02:08:27

not bad for a first script. Needs word done. It appears to me that you have the fundamentals of SCAR down. good job =)

elvis633

2009-06-10 04:23:11

Its probebly just me but after a while as with most miners i use it stops mining the ore and just sits there till i log out is there a point in the script i missed like a timer for how long it will continue?