SRL Archive - Outdated Tutorials

Getting started to learn how to script


Iron Man

2008-03-19 23:38:55

If this isn't understandable enough tell me which part i should re-explain.
If you want me to add something tell me.

I know i didn't use the exact syntax from SRL but i thought this would be more understandable to new scripters.

Now to start the tutorial.

Making your first script

When you open Scar it should look like


program New;
begin
end.


program isn't needed but just leave it.
begin starts a procedure/function.
end. with a period terminates the script

We want to change it to

program New;
{.include SRL/SRL.scar}
begin
SetupSRL;
end.

That includes the most important of the SRL Folder. SetupSRL isn't needed to include SRL but it is needed later on, for mouse functions.

You can make procedures and functions easily, just do something like…

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

procedure FindTree;
begin
end;

begin
SetupSRL;
FindTree;
end.


You can Change FindTree; to anything, but in the "loop" of the script you need to change where it says FindTree; to the name of your procedure. Also notice how the end has a semicolon instead of a period, it has to be a semicolon for a procedure or function in a script. You need to put a end; for every begin so your thing could be like this.

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

procedure FindTree;
begin
begin
begin
begin
end;
end;
end;
end;

begin
SetupSRL;
FindTree;
end.


But you don't need that right now.

Now the undetectable mouse function is, Mouse/MMouse. Who would've guessed.
MMouse moves the mouse and doesn't click, Mouse moves the mouse and either clicks left or right click.

Syntax for MMouse is:

MMouse(x, y, 3, 3);

Syntax for Mouse is:

Mouse(x, y, 3, 3, true);

Change x, y to the coordinates (Conrol+Alt+P then click on the spot you want it to click)

the 3,3 is the amount of pixels it can go away from the destination. (Just leave it if you don't understand

The True in Mouse can be changed to false also, True = Left click, False = Right Click

Or for coordinates you can call them as variables by doing this


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

var
x, y: integer;

procedure FindTree;
begin
end;

begin
SetupSRL;
FindTree;
end.

See how its right after the program
That means it can be used for all of your procedures and functions, but with a number every time.
integer means its a number if you didn't know.
Also theres
String (a word/letter)(used by putting ' ' before and after the string)

Boolean which is true or false.



Now for how to find colors.

For the most effective easy ones IMO are these

FindColorTolerance

FindColorSpiralTolerance

FindObjCustom


Syntax for FindColorTolerance is like

FindColorTolerance(x, y, YourColor, msx1, msy1, msx2, msy2, 10);

You should understand the x, y now so moving on.

For YourColor change it to whatever color you want it to click on. (Control+Alt+P then find the color you want and click on the spot.

msx1, msy1, msx2, msy2 is the box it looks for it in. msx1, msy1 etc would look in the mainscreen.
mmx1, mmy1 etc would look in the minimap for the color.
mix1, miy1 etc would look for the color in the inventory.

The 10 means the tolerance. You want tolerance because the colors in runescape change. Anywhere from 5-15 tolerance is good.



Syntax for FindColorSpiralTolerance is the same as FindColorTolerance


Syntax for FindObjCustom is:


FindObjCustom(x, y, ['Your UpText here'], [YourColor], 10);

Notice how i used the different kinds of brackets… use those kind for those 2 things.
The 10 in here is the tolerance again.

For 'Your UpText here', change it to the text that comes up when you hover over something. Make it look for only lower case letters so for example for when it says Mine Rocks use this
'ine'

So it would find the ine in the Mine.

I explained the x, y and the YourColor already.

Now to use it in a procedure.


procedure FindTree;
var
x, y: integer;
begin
if FindObjCustom(x, y, ['ut'], [TheColor], 10) then
Mouse(x, y, 3, 3, true);
end;

Also SetupSRL; makes the mousespeed for Mouse and MMouse to a regular speed.

For the variables, you can also add them under a procedure or function, but it can only be used for that one procedure/function.

Now your probably asking, when did we cover if/thens?!!?!?!?!?!?

But I'll explain it. If it were to find that then it will continue with the procedure, if not then it will leave it.
Also if you have if()then's add begin and ends otherwise it will only do the first line right after it.

Now since they both have x, y it will find the color in that spot and record that spot as being x and y, making the mouse move to those coords that it found the color.

So now your whole script would look like this:

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

var
x, y: integer;

procedure FindTree;
begin
if FindObjCustom(x, y, ['ut'], [TheColor], 10) then
Mouse(x, y, 3, 3, true);
end;

begin
SetupSRL;
FindTree;
end.


For your loop you can also add a repeat/until

So your loop which looks like this:

begin
SetupSRL;
FindTree;
end.

Could look like:

begin
SetupSRL;
repeat
FindTree;
until(false);
end.

That will keep doing it over and over again, false doesn't stop doing it. Theres a lot of different until() things but I don't feel like explaining it right now.

You can also make waits or sleeps.

Syntax of Wait/Sleep is:

Wait(1000);

the numbers are in milliseconds and it will wait that many milliseconds, but that will look suspicious if you wait the same amount of time every time, so you want to add a random to it


Wait(1000 + Random(1000));

That will wait anywhere from 1 second to 2 seconds.


Inventory item finding & dropping

For the simplest inventory item finding, would be:

MouseItem(invspot: Integer; left: Boolean);
And

MMouseItem(invspot: Integer);
Example of how to use MouseItem would be:

MouseItem(1, true); //That will left click on the first inventory slot.

Although those can be useful, they're not always the best to use.

DTM's are accurate when done right. They can be used for more than inventory finding, but I'll just show how to for this.

First of all open SCAR.

Make it smaller so you can see your item in your inventory.

Go to Tools>DTM editor like so:


You now want to click on the near the middle of the item. Now look at the left side of your DTM editor. It will look like this:

For a normal DTM you in the tolerance part you will want to make it 5-15 tolerance. For a universal DTM (one that works with all types of the item your making (Iron ore, tin ore, copper ore, etc) then you will want 255 tolerance.

Now to make the Sub Points.

Your going to want to click on the black outline of the item you have. About 4 sub points works good. NO TOLERANCE ON THE BLACK OUTLINE. The color of the black outline will be 65536.

So the item should look like this (not iron ore but the idea)

To get the DTM, on your DTM editor, go File>DTM to Text

The DTM will end up in your Debug box. Close your DTM Editor. The DTM should be random letters and numbers like this

DTM := DTMFromString('78DA63DCC3C4C0B08D91011978E9298369982' +
'8E37EA09A55A86A60B27035A7806A361250B30BA8E60801356B30' +
'DD83AE0600631D07EF');

You can change the DTM part to whatever you want to call it.
Make the name of your DTM a global variable.

To find the DTM in your inventory you would use:

FindDTM(DTMname, x, y, mix1, miy1, mix2, miy2);

And remember to free your DTM like this:

FreeDTM(DTMname);

Dropping the inventory:

Simple dropping methods:

To drop all your items in your inventory, you will want to use

DropAll;
To drop a single item you will want to use

DropItem(inventory spot);

To drop from inventory spots 2-28.

procedure Drop2to28;
var
i: integer; //Declares i as a integer
begin
for i := 2 to 28 do //Makes i go from 2 to 28
DropItem(i);
end;


Anti-Ban and Anti-Randoms
To use a AntiBan procedure in your thing make a procedure like this

procedure AntiBan;
begin
end;

Now we want to add a case Random after the begin.

procedure AntiBan;
begin
case Random(100) of
end;
end;

You need to add a extra end; because the case random is kind of like a begin i guess.

Ok explained my other tutorial in a Wait procedure if you do this

Wait(1000 + Random(1000));

It will wait a 1 second to a max of 2 seconds.

Same sort of thing because you need numbers in this, Random(100) will pick a number between 0-99 and Random(50) will pick a number between 0-49.

So the higher the number the less chance it will do the AntiBan, but if you have it in one of your procedures in the loop or just in your loop.


So look around SRL's AntiBan folder to see what function you want to use. For this tutorial I will use BoredHuman; and RandomRClick.

This is how I do my AntiBan; but I'll show a different way but with less in it.


procedure AntiBan;
begin
case Random(20) of
0: begin
Wait(50 + Random(1000));
Boredhuman;
Wait(50 + Random(1000));
end;
1: begin
Wait(50 + Random(1000));
RandomRClick;
Wait(50 + Random(1000));
end;
end;
end;


You can add as many numbers as you want, just put it in consecutive order. So its like having procedures within the procedure which it picks a random one at a random time (the higher the Random number the less chance that it happens).

You can also get rid of the begin/ends; at the one part, but you can't have more than 1 function in it.

You could also change the last one into this to make it shorter.


procedure AntiBan;
begin
case Random(10) of
0: Boredhuman;
1: RandomRClick;
end;
end;


So you could add that to the part where it mines/cuts/fights the monster after its done or whatever your doing. Or you could add to your main loop.


For Anti-Randoms, the only one you really need to use is

FindNormalRandoms;

You want to add that to most of your loops. Add it to other places to.

Dracody

2008-03-20 00:21:22

Nicely explained :D good for the guys learning to script :p

Iron Man

2008-03-20 23:50:15

Thanks, I wasn't sure if I explained this clear enough.

dver

2008-03-26 17:11:32

lol :) this made me understand some things about SRL/SCAR scripting :D

skilld u

2008-03-27 16:15:59

very nice. helpful for t3h noobs. :p

supermoose

2008-03-28 12:54:14

From: skilld u
very nice. helpful for t3h noobs. :p


yes it helped me xD
thanks man _o_

DeSnob

2008-03-30 07:05:56

reallly helped =) im making an ess miner hope i works >.<

Heartrange

2008-03-31 02:26:23

Very nice I understand it now a litle bit :p

XRaye

2008-04-16 01:43:20

I think this tutorial is very well explained, it helped me and i couldn't be where i am in my power cutter without your help.

Iron Man

2008-04-16 01:45:43

Thanks, is there anything you think that I should add?

XRaye

2008-04-16 11:05:42

There is always more that can be added, it just depends on what you want to teach. You could add DTMs, in less you think that would be too advance for this tutorial.

Iron Man

2008-04-17 14:33:18

Added Item Finding & Dropping and Anti-Ban and Anti-Randoms. If anyone notices a part that doesn't make sense, please tell me so I can make it more clear.

X Gilli X

2008-04-17 15:42:05

From: Iron man
Added Item Finding & Dropping and Anti-Ban and Anti-Randoms. If anyone notices a part that doesn't make sense, please tell me so I can make it more clear.


It's really a good tut. Good job.

;)

skilld u

2008-04-17 16:41:42

very nice :p it is very thorough and helpful. good work :D

SKy Scripter

2008-04-17 17:38:08

Yay, now i can make me a hello world script.
Thanks :)

Rep –

P1nky

2008-04-17 18:35:53

LOl sky havent seen you post like that:P

faster789

2008-04-17 22:44:04

Nice TUT! Nicely explained with great detail!
REp++;)

Iron Man

2008-05-04 13:43:04

So does anyone feel that I can add anything/explain something more thoroughly?

Thanks for the nice comments :)

Java Lava

2008-05-05 14:50:56

Great TuT Rep ++ !!

Timer

2008-05-05 16:19:23

Fix Somthing :D

  If FindObjCustom.... Then
Mouse(X, Y, 5, 5, True);

Should Be..

  If FindObjCustom.... Then
Mouse(X, Y, 5, 5, True);

As In There Is No Begin, The 1 Command Acts Like There Is.

Iron Man

2008-05-05 18:10:51

I don't get what you mean. I know you need a begin if you have a if/then if you want to do more than one thing, its just not in my standards to have 2 spaces after a if/then.

If you mean if I have to have a 2 spaces after a if/then otherwise it does everything, I'm pretty sure your wrong there.

vengence

2008-05-05 21:13:21

is there anything i should learn before i start scripting??

Iron Man

2008-05-05 22:31:11

All the stuff in this tutorial you should learn, and some more in other tutorials.

Timer

2008-05-05 23:29:20

if(I = 42)or(J = 42)then
CallProc(AParameter);

Official Standards.

PWNT! :D

Iron Man

2008-05-05 23:34:41

I said its not within my standards, not everyone has the exact standards as the official ones. Personally I think the space after the if/then is ugly.

Timer

2008-05-05 23:38:38

If its a tut, it MUST be all official. :D

FSGood74

2008-05-06 10:48:14

everything i ever needed to kno is in this post

Iron Man

2008-05-07 18:08:59

From: Timer
If its a tut, it MUST be all official. :D


I never said its not official, I was just saying that I don't like to do that in my standards.

AlexNingsuenPahn

2008-10-25 16:45:42

nice, thx!

Riffe

2008-12-13 07:02:57

Nice tut!
This tut will help me to make my own script:D

gamer0n1

2009-01-25 13:24:36

thank you so much for this amazing tutorial! It explains everything!

mazo1

2009-01-27 15:23:04

This kinda of helped him i might start to script but im not sure how you mentioned this but do you know how can make it bank for example:

I want to make a willow chopper + banker so after i have got all the color and stuff how could i make it know to bank like have a full invt get me? lol

Kryptic

2009-04-20 04:55:19

WOW! I learned A LOT!! Thanks soo much Iron man :)

~Kryptic

mr-sjb

2009-04-27 14:52:11

ty it helped me a bit:) going to try one on my own now:)

Kryptic

2009-05-02 10:49:29

Repped ftw, always come back to this post for info :)
Thanks so much!

Mystic

2009-05-04 00:05:21

OMG!! I learned so much from this.. literally.. Thank you!! :)