SRL Archive - Outdated Tutorials

A good first script


JAD

2007-06-05 19:20:40

Well, with all the people I help over msn, I've found one common problem they've all had. "Where do I start?" Well, just take a look at this script, and I will explain everything before

NOTE: Before reading this, you should have already read one or more of the stickied beginner tuts on learning scar, and probably the first chapter of my tut Things the beginner tuts don't teach you. Then, if you get all that, you should get ready.

Here's the script:

program PowerMiner;
{.include SRL/SRL.scar}

const
TheRockColor = 12345; //put the rock color here.
Equiped = True; //Is the pick axe equipped?

procedure MineRocks;
begin
repeat
if(FindColorTolerance(x,y,TheRockColor,MSX1,MSY1,MSX2,MSY2,3))then
begin
MMouse(x,y,2,2);
if(IsUpText('ine'))then
begin
Writeln('Found the rock! Clicking now');
GetMousePos(x,y);
Mouse(x,y,0,0,true);
end;
end;
wait(1000+random(1000));
until(InvFull);
end;

procedure Drop;
begin
GameTab(4);
if(Equiped)then
DropAll;
if(not(Equiped))then
DropTo(2,28);
end;



begin
SetupSRL;
ActivateClient;
wait(500+random(500));
repeat
MineRocks;
Drop;
until(False);
end.

See that? You should already know of just about everything in that already! And it's so simple. If you don't already know, here's what this script should do:

It should repeat clicking the rock and waiting random 1-2 seconds then clicking the rock again until your inventory is full.

Then, once the inventory is full it should drop everything in your inventory except your pick

Now lets me first explain my logic behind the Equipped thing. What that is, is in the dropping procedure, if the pick is equipped, (the user would set Equipped to true) the script will drop everything in your inventory.

If the pick is not equipped, (the user would set Equipped to false) it will drop everything except whats in the first inventory slot (hopefully where the user put there pick :) You should tell them in comments to do that at the beginning of the script).

So in the mining procedure, we look for the color the user put as TheRockColor with a tolerance of 3 on the main screen.

If it finds it, we move the mouse to the color and 2 random pixels up down left and right. Then, if the text 'ine' (AKA, shorter word of Mine) is up, it will save the position of the mouse to x,y and click there.

The reason for GetMousePos is because you don't want to move the mouse to the rock, check the up text then click somewhere else; you want it to click the same spot it moved there to after checking the up text for less detectability/more reliability.

We have it wait 1-2 seconds after clicking the rock, then it does it again. It repeats until the inventory is full.

You could put in the constants WaitTime or something so the user can set how long to wait, then do something like Wait(WaitTime + random(500)); so the user can set it according to there pick/mining level.

Then in the main loop we have it setup srl, activate the client (box down scar), it waits around half a second while boxing down scar just in case you lag a bit or something, and after that it just repeats mining until the inventory is full and then dropping until the user stops the script.


Although this is a very basic script, it still is the way a LOT of scripts work these days, maybe just a little more advanced with more fail safes for more reliability, but this should get the job done for a little while.

So it's not a very good over night script, but after you add anti randoms/anti ban/multi player/fail safes, it could work for a decent amount of time.

To learn about those things, check out my tut (links in sig) Learning the things to become a SRL member, and it should teach you all that :)

Thanks for reading my very short tut, hope that helps you know where to get started with your first script!

Sp0rky

2007-06-05 19:28:08

haha, pretty nice beginner tut. Maybe you should comment your code to make it slightly clearer what each line of code is actually doing? Just a suggestion.

Thx for the tut, im sure lots of beginners will find it useful.

JAD

2007-06-05 19:33:40

From: Sp0rk-eh
haha, pretty nice beginner tut. Maybe you should comment your code to make it slightly clearer what each line of code is actually doing? Just a suggestion.

Thx for the tut, im sure lots of beginners will find it useful.


The only reason I didn't do that is because they should already get what everything I used in that script does, and should just need a brief over viewing on how I used it, and they should be able to get it if they read the tuts I specified :p

Anyways, thanks :) I know it was pretty short/dumb, but a lot of people don't know where to start, so this is where :)

farfen

2007-06-05 21:03:42

thanks this really helped me get started with my first script

JAD

2007-06-05 23:40:42

From: farfen
thanks this really helped me get started with my first script


Good! Glad this tut helped somebody :)

Thanks for posting.

decide

2008-07-23 19:22:03

I had to declare x and y as integers before the script would work.

Just put this at the beginning of the script (above the constants).

var x,y : integer;

Minkino

2008-09-28 04:12:08

What should I use instead of DropTo considering its not in SRL anymore.

Found out new function DropItem.

Procedure DropOres;
var
i : Integer;
begin
if invfull then
begin
for i := 2 to 28 do
begin
DropItem(i);
Wait(RandomRange(501, 1501));
end;
end;
end;

That will drop from 2 - 28. Thanks and Cred to Cazax