PDA

View Full Version : Taking apart a script (My willow chopper)



JAD
04-11-2007, 11:25 PM
Update: Huge update, april 12th. Added a glossary and changed some things in the breaking apart the script part after the glossary. Please read it over if you haven't already and post feed back! That'd be awesome :) thanks.

This tutorial took me a LOT of time to write, so please, post FEEDBACK on it :D

When you have been learning to script for about a week or so, you may already know how to put together your first complicated, very useful script without even knowing it! In this tutorial, I will be using my script JADWillow, which is a willow anced now isn't it?" Well, I'm here to tell you, it really isn't! I am going to break this down as much as possible to help you understand how the script works. Heres what this script will demonstrate, and will hopefully teach you:





How to walk the map without walking near water/roads (wow, that sounds hard eh? :p)

The use of Anti Randoms in your script, and how/when they should be called for.

The use of Anti Ban and when you should be using that.

The use of player arrays/using multiplayer, which kind of goes along with Anti Randoms in a way.

The use of the almighty progress report. (which every good script should have in my opinion.)

The use of a LOT of fail safes. In this script, there will be a lot and you will be taught just how important they really are.

The use of opening a bank, depositing Items, closing the bank and some other things.

A nice and neat main loop.




Here is the glossary for just about every single command I use in this script, and what they do!


Note: I did not add parameters on the commands, though I will explain how the parameters should be used :) for every command I explain that has parameters, I will put a little example from my script on how I used it in there, then explain.




Glossary:


ActivateClient;

This will activate the client.

(in case you don't know) the client is the cross hair you drag on to runescape. So what this means, is if the user dragged the cross hair onto the runescape window correctly, it will activate that, boxing down SCAR.

usually used at the beginning of the main loop, before a repeat so that SCAR doesn't block the runescape screen.




AutoColorThis;

Heres how this is mostly used in my script:


GBankColor := AutoColorThis(BankBMP, 50, MMX1, MMY1, MMX2, MMY2);

So that is how I used it mostly. Heres what you fill the parameters in with.

GBankColor is where you fill in the color you want it to save it too, you must declare that as a variable though as I did in my script.

AutoColorThis is the command of course :p BankBMP is the bitmap which you also need to declare as a variable, and then put the picture in for it like BankBMP := ..etc. as I did in my script.

50 Is the maximum tolerance you want the command AutoColorThis to look for the bitmap with.

the rest is just parameters for where you want it to Auto Color it at. MM stands for mini map, so that would look for it on the minimap.

Once it does all this, if it finds the bitmap you made, it will save the color to the GBankColor variable (or whatever you made it, thats just what I used) This is great to use when you are walking somewhere without a road/water.




ChooseOption;

Heres how this is mostly used in my script:

[Size="3"]ChooseOption(x, y, 'All');

What you put between the '' is the option you want it to choose when right clicking on something like a log or something. And you just put the variables in front of it like so.

In this, it just chooses the Option All (Deposit All) for the banking.




ClearDebug;

This completely wipes out the whole debug of everything and makes it blank.

Very useful for when you are Writing a progress report, and you want a fresh one instead of more then 1 progress report, so you always get the current one.




CloseBank;

This command simply closes the bank window, clicking the the X on the runescape screen (which closes it :p)




Exit;

How this is used mostly in my script:

if(not(LoggedIn))then
Exit;

You may not know about logged in, if not, read about it below. What this does though, is if the user isn't logged in, it Exits the whole procedure/function you are in ignoring everything after it.

note: you do not have to use this with logged in, you can use it with a lot of other things too.




FindBitmap;

How it is mostly used in my script:

if (not (FindBitmap(BankBMP, x, y))) then

you should already know about if, then and not's. But heres what this does. FindBitmap is the command, which searches for the bitmap, results true if found.

Also if found, it saves the location of it to x,y (the variables) so you can make it click that location or something like that later.

BankBMP you would have to declare as a variable, and as a bitmap and you could name it whatever you want as long as the variable is the same.




FindColorTolerance;

How it is mostly used in my script:

if (FindColorTolerance(x, y, WillowColor, 160, 97, 516, 209, 3)) or
(FindColorTolerance(x, y, WillowColorB, 160, 97, 516, 209, 3)) or
(FindColorTolerance(x, y, WillowColorC, 160, 97, 516, 209, 3)) then

Well, heres what this does. FindColorTolerance looks for the color in a coordinates box with tolerance and saves the location of it to x,y (the variables). Here, I have it look for WillowColor, or WillowColorB, or WillowColorC which are all are constants.

the 160,97,516,209 is the coordinates box to look for the color in obviously. and the 3 after the coordinates box is the Tolerance to look for the color with.

Tolerance is used in case the color changes slightly, which Jagex does a lot to try to throw off our colors, causing us not to be able to auto. Luckily, we can look with tolerance! the higher the tolerance, the higher off it can go from the color. I like 3 as my tolerance.

note: you do not have to have all those or's, you could have it just look for 1 color. I have it do that so if it doesn't find 1 of the colors, it will still search for the next one.




FindDTM;

Heres how this is mostly used in my script:

if (FindDTM(Willow, x, y, 568, 209, 742, 460)) then

You should already know about if then else. FindDTM looks for the DTM you declared as a variable, and of course you declared the DTM text.

If you do not know how to make DTM's, read Yohojo's tutorial on it in the intermediate section of tutorial island (on SRL forums)

So in my script I called the DTM Willow. So if it finds that DTM in the coordinates box I made it look for it in (the inventory) it saves the location of it to x,y (the variable)




FindEnt;

Heres how this is mostly used in my script:

if (FindEnt(WillowColor)) then

You should already know about if then else. Now, FindEnt looks for an ent (the dancing tree that breaks your axe) and if it finds it, it results true.

the (WillowColor) is the color of the tree which you are chopping, and it uses that to check for the ent.

In my script I make it run away if it results true that the ent was found.

note: SRL's FindEnt (what we are talking about here and I have in my script) does not normally work. I am working on my own custom ent finding procedure, and you should make your own too if you want good ent detection.




FindNormalRandoms;

This finds and solves all the normal randoms (All talking randoms, Mystery box, lunch lady, fights....etc).

note: this does not solve all impossible to solve randoms. That includes evil bob and some others. For talking randoms, you need to use the Bitmap maker for your nick. Read about that below to learn more about that.




FixBank;

This simply scrolls the bank up to the top if it wasn't already.




Flag;

This repeats waiting until it doesn't find the red flag on the mini map. (when you click on the mini map, the red flag appears if you didn't already know :p)




HighestAngle;

This simply puts your charactor at the highest possible angle of view.




InvFull;

Heres how this is mostly used in my script (well, not mostly for this one, but this is the easiest example :p):

until (InvFull);

And what that does, is of course I have a repeat above it, it repeats the code until the Inventory is full. So pretty much, once the inventory is full, it results true.

This is used a lot in anything the chops/mines/fishes...etc. to detect When to bank/drop or whatever.




IsUpText;

Heres how this is mostly used in my script:

if (IsUpText('illow')) then

What this does is checks for the text in the upper left corner that you put between the '' .

I used this after moving the mouse to the color of the willow (and more things) then to check if the text in the upper corner says illow (AKA Willow, illow is shorter and you should try to avoid using Capitals)

So this is useful when moving the mouse to a color, and making sure that the color was of what you wanted (the willow in this case) because the color of the grass for instance could have some of the same colors as the willow.




LoggedIn;

This simply results true if an account is logged in. Mostly used in my script as:

if(not(LoggedIn))then
Exit;

note: If you do not know about exit, you should read about that above.

So this checks if your logged in, and if not it exits.




MakeCompass;

Heres how this is used mostly in my script:

MakeCompass('N');

So what MakeCompass does is just puts the compass to the angle you put between the '' . N for north, S for south, E for east and W for west.

note: It does not get the compass to a perfect angle, but it gets fairly close.




MMouse;

Heres how this is mostly used in my script:

MMouse(x,y,2,2);

So heres what this does. MMouse moves the mouse to specified location and does not click. x,y is the variables which a location should have been saved too by using FindColorTolerance or something like that (read above if you don't know about that)

The 2,2 are random pixels to go off by so the mouse doesn't always move to the exact same spot every time to keep more undetectable to Jagex.




Mouse;

Heres how this is mostly used in my script:

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

Now heres what that does. Mouse moves the mouse the same way MMouse does, the 2,2 are random pixels just like in MMouse. The only difference between MMouse and Mouse is that Mouse clicks, and MMouse doesn't.

The true in Mouse is for the clicking. True for left click, False for right click.




NextPlayer;

Heres how this is mostly used in my script:

NextPlayer(True);

What this does, is logs in the next player thats active in the player array.

Now, heres what the true/false would do. if you have NextPlayer(True), that would log in the next player and leave the Active option on the one you logged off of to true. So this means that the script would go over charactors multiple times, unless you terminate the script at a different time or something like that.

NextPlayer(False) Would switch charactors, and leave the Active option on the one you logged off of to false. So the next time that your script goes to the next player, the one you just logged off of would be false so it wouldn't log onto that one again.

I only use NextPlayer(False) if something went wrong (like that player got lost or something), and NextPlayer(True) if everything went well and you are just switching because the desired loads are done or something.




NickNameBMP

Heres how this is used:

NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);

Now, heres what this does. in FindNormalRandoms, to solve talking randoms you need this.

What this does, is creates a bitmap mask of the current player's .Nick in the DeclarePlayers procedure.

So just put this in your declare players procedure, and call for the procedure in the main loop before any repeat and you should be good to go.




OpenBankQuiet;

Heres how this is used mostly in my script:

OpenBankQuiet('eb');

What OpenBankQuiet does is opens the bank you put between the '' . (eb= edgevil bank, vwb would = varrock west bank...etc.)

The difference between OpenBankQuiet and something like OpenBank, is the OpenBankQuiet tends to lag a little bit, but it opens the bank without any weird mouse movements like thinking the bank is somewhere else when it isn't.




PopUp;

Here is how this is mostly used in my script:

PopUp('ontinue')

What this does, is if it finds the popup and the text ontinute (Continue) it would click what you put between the '' , in this case it would click 'ontinue'.

a pop up is something like when you get a level up or something like that.




RadialWalk;

Heres how this is mostly used in my script:

RadialWalk(GBankColor, 270, 290, 68, 2, 2);

In this script, I used auto color this for a bitmap and then saved that color to GBankColor. (if you don't know about autocolorthis, read about it near the top of the glossary)

The 270, 290 is the angle of the mini map you want to look for the color GBankColor in. Its just basic geometry. if those numbers were 90,180 , it would search the bottom right quarter of the mini map for that color...etc. Try using yakmans radial walking aid located in the SRL scripts folder.

the 68 is the radial, which is how far out from the center of the mini map it looks for the color (of course that goes alon with the 270,290)

the 2,2 are random pixels to click so the script doesn't click the same spot all the time. (just like in MMouse and Mouse)




RunAwayDirection;

Heres how this is used mostly in my script:

RunAwayDirection(DirToRun);

RunAwayDirection is usually used to run away from something, like a fight, ent...etc.
DirToRun is a constant I made that the user sets on which way to run if it finds a fight in this case.

So lets say the user set DirToRun to 'N'. the script would then run north if a fight was found, wait a little bit, and then use RunBack; (which I will explain right below this)




RunBack;

This is used with RunAwayDirection. Once it runs away from something like a fight, it will run back using this. So if it ran away in the direction north, it would run back south so it gets back to the same spot you were in.




SetupSRL;

This calls to setup the almighty include SRL. If you are using SRL, You need this in your main loop before any repeat (if you have any) for the script to work.




SleepAndMoveMouse;

This moves the mouse around randomly like a bored human would. heres how this is used mostly in my script:

SleepAndMoveMouse(9671 + random(1709));

This Moves the mouse around randomly like a bored human would every 9671-11380 milliseconds. Its good to add randomness to it like I did here or else it will be very detectable to Jagex.




SRLRandomsReport;

This writes in the debug the randoms your script has encountered. Normally used in the progress report procedure like I did.




TerminateScript;

This kills/ends the script. nothing else happens after this because the script stops :p




Wait;

Used like this

Wait(1000+random(500));

This just waits 1000-1500 milliseconds. Greatly advised to put a random in like so or it will be very detectable to Jagex.




Writeln;

Heres how it would be used:

Writeln('Hello world!');

It just writes in the debug box whatever you put between the '' .



If you do not understand any of the commands below, please look them up in the glossary and they should all be there :)
Now, lets begin!

Heres the script, it may freak you out at first, but don't worry! below I will explain Everything with extreme detail. Here you go:

{//-----------------------------------------------------------------------------\\
This script will chop willows at edgevil bank. Start ALL active players
at edgevil farthest east bank slot. Axes weilded or un weilded. This script
does NOT feature axe head finding, Will add soon. Do setup and do setup for
DeclarePlayers on lines 28-68. Please remember to post proggies where you
got this script :) Happy autoing!
//------------------------------------------------------------------------------\\}

program JADWillow;
{.include SRL/SRL.scar}
{.include SRL/SRL/Skill/WoodCutting.scar}
const
//------------------------------------------------------------------------------\\
//-------------------------------> Setup <--------------------------------------\\
//------------------------------------------------------------------------------\\

DirTorun = 'N';
Loads = 10; //Loads to do before switching players.

//------------------------------------------------------------------------------\\
//----> Auto Colors Only set these if the script is not finding the Willow <----\\
//------------------------------------------------------------------------------\\

WillowColor = 5398624; //Color of willow tree on Main Screen
WillowColorB = 3174496; //another color of willow on Main Screen
WillowColorC = 4293865; //another color of willow on Main Screen

//------------------------------> End Setup <-----------------------------------\\

// DO NOT TOUCH THESE! \\
var GrassColor, GrassBMP, BankBMP, GBankColor, Tries, Willow: Integer;
EntCount, LoadsNum, LoadsNumB, BushWater, BushWaterColor: Integer;
DidRandomHappen: Boolean;
// \\
{************************************************* *************************

----------> Setup Players here <----------

************************************************** ************************}

procedure DeclarePlayers;
begin
HowManyPlayers := 6; //Number of PLAYERS. active or not.
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0; //Player to start on.

//set all user names, passwords and nicks correctly please.

Players[0].Name := 'Jadseven';
Players[0].Pass := 'Password';
Players[0].Nick := 'dsev';
Players[0].Active := True;
Players[0].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot

Players[1].Name := 'UserName';
Players[1].Pass := 'Password';
Players[1].Nick := '3-4 letters of UserName';
Players[1].Active := False;
Players[1].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot

Players[2].Name := 'UserName';
Players[2].Pass := 'Password';
Players[2].Nick := '3-4 letters of UserName';
Players[2].Active := False;
Players[2].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot

Players[3].Name := 'UserName';
Players[3].Pass := 'Password';
Players[3].Nick := '3-4 letters of UserName';
Players[3].Active := False;
Players[3].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot

Players[4].Name := 'UserName';
Players[4].Pass := 'Password';
Players[4].Nick := '3-4 letters of UserName';
Players[4].Active := False;
Players[4].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot

Players[5].Name := 'UserName';
Players[5].Pass := 'Password';
Players[5].Nick := '3-4 letters of UserName';
Players[5].Active := False;
Players[5].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot
NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
end;
{ don't touch below unless you know what your doing! }

procedure Signature;
begin
ClearDebug;
writeln(' JAD willow chopper by yours truely:');
writeln(' __________ /\ ______ ');
writeln(' |__________| / \ | ____ \ ');
writeln(' | | / /\ \ | | \ \ ');
writeln(' ___ | | / /__\ \ | | \ \ ');
writeln(' \ \| | / /____\ \ | | / / ');
writeln(' \ | / / \ \ | |___/ / ');
writeln(' \____|/ / \ \|______/ ');
wait(3000 + random(750));
end;
{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Random Finding <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

function FindFastRandoms: Boolean; //By WT-Fakawi.
var
i: Integer;
begin
for i := 1 to 8 do
begin
case I of
1: if FindDead then
Result := True;
2: if FindMod then
Result := True;
3: if FindMime then
Result := True;
4: if FindMaze then
Result := True;
5: if FindQuiz then
Result := True;
6: if FindDemon then
Result := True;
7: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
end;
7: begin
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Logout;
Exit;
end;
end;
8: RC;
end;
wait(1);
end;
if (Result = true) then
DidRandomHappen := true;
end;

///////////////////////////////////////////////////////////////////////////

procedure FindRandoms;
begin
FindFastRandoms;
FindNormalRandoms;
if (FindNormalRandoms) then
DidRandomHappen := true;
if (FindEnt(WillowColor)) then
begin
RunAwayDirection(DirToRun);
Flag;
Wait(5000 + random(1500));
RunBack;
DidRandomHappen := true;
EntCount := EntCount + 1;
end;
end;
{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> JAD Proggy <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

procedure JADProggy;
begin
ClearDebug;
Writeln(' Please Check out + register on me and pwnaz0rs forums at: ');
Writeln(' Uberbroproductions.net/forums ');
Writeln('[]=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ');
Writeln('|| JAD Progress report. Please remember to post ');
Writeln('|| proggies/bugs wherever you got this script :) ');
Writeln('[]-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ');
Writeln('|| Worked For : ' + ScriptTime2(2));
Writeln('|| Did ' + IntToStr(LoadsNum) + ' Loads ');
Writeln('|| Avoided ' + IntToStr(EntCount) + ' ents ');
Writeln('||=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ');
Writeln('||Thanks for using JAD Willow, happy autoing :) ');
SRLRandomsReport;
end;
{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Walking to Willow <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

procedure WalkToWillow;
begin
MakeCompass('N');
GrassBMP := BitmapFromString(8, 10, 'z78DA33333177357433A' +
'335E9483439D8D4E3275D2D0CD1C841A61E006F046F69');
BushWater := BitmapFromString(1, 1, '183D00');

BushWaterColor := AutoColorThis(BushWater, 50, MMX1, MMY1, MMX2, MMY2);
RadialWalk(BushWaterColor, 75, 105, 70, 2, 2);
wait(6000 + random(1500));
Flag;
Wait(200 + random(100));
Tries := 0;
repeat
if(Tries = 40)then
begin
Writeln('Could not find willow... :( terminating script..');
TerminateScript;
end;
wait(300 + random(150));
Tries := Tries + 1;
until (FindColorTolerance(x, y, WillowColor, 160, 97, 410, 340, 3)) or
(FindColorTolerance(x, y, WillowColorB, 160, 97, 410, 340, 3)) or
(FindColorTolerance(x, y, WillowColorC, 160, 97, 410, 340, 3));
end;
{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Walking to Bank <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

procedure WalkToBank;
begin
if (InvFull) then
begin
MakeCompass('N');
BankBMP := BitmapFromString(7, 7, 'z78DAB370B430B230B0' +
'00938E469616966698A4B993B9B1B991050D54228B20EB422 6078' +
'34A00FBA54003');
if (not (FindBitmap(BankBMP, x, y))) then
begin
Mouse(627, 88, 8, 8, true);
Flag;
end;
GBankColor := AutoColorThis(BankBMP, 50, MMX1, MMY1, MMX2, MMY2);
RadialWalk(GBankColor, 270, 290, 68, 2, 2);
Flag;
wait(200 + random(100));
end;
end;
{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Willow Chopping <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

function ChopIt: Boolean;
begin
repeat
if (not (LoggedIn)) then
Exit;
if (FindColorTolerance(x, y, WillowColor, 160, 97, 516, 209, 3)) or
(FindColorTolerance(x, y, WillowColorB, 160, 97, 516, 209, 3)) or
(FindColorTolerance(x, y, WillowColorC, 160, 97, 516, 209, 3)) then
begin
MMouse(x, y, 3, 3);
if (IsUpText('illow')) then
begin
Mouse(x, y, 2, 2, true);
repeat
if (InvFull) or (PopUp('ontinue')) then
Exit;
if(DidRandomHappen = true) then
begin
DidRandomHappen:=False;
Mouse(x, y, 2, 2, true);
end;
FindRandoms;
SleepAndMoveMouse(9671 + random(1709));
FindRandoms;
until (not (FindColorTolerance(x, y, WillowColor, 160, 97, 410, 340, 3))) or
(not (FindColorTolerance(x, y, WillowColorB, 160, 97, 410, 340, 3)))or
(not (FindColorTolerance(x, y, WillowColorC, 160, 97, 410, 340, 3)));
repeat
if (InvFull) or (PopUp('ontinue')) then
Exit;
if(DidRandomHappen = true) then
begin
DidRandomHappen:=False;
Mouse(x, y, 2, 2, true);
end;
wait(750+random(250));
FindRandoms;
until (FindColorTolerance(x, y, WillowColor, 160, 97, 410, 340, 3)) or
(FindColorTolerance(x, y, WillowColorB, 160, 97, 410, 340, 3)) or
(FindColorTolerance(x, y, WillowColorC, 160, 97, 410, 340, 3));
Result := True;
end;
end;
until (InvFull);
end;
{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Banking Willows <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

function BankIt: Boolean;
begin
if (InvFull) then
begin
Willow := DTMFromString('78DA63FCC4C4C0D0C9C8800A1819FE83490 68' +
'6FF40C0C8C08C550D8204D2AC40355308A86104AA994940CD 37A0' +
'7BE61050F31AA8A68F0835B3F0AB010040990CF0');
MakeCompass('S');
wait(250 + random(167));
OpenBankQuiet('eb');
Flag;
wait(500 + random(267));
FixBank;
if (FindDTM(Willow, x, y, 568, 209, 742, 460)) then
begin
Mouse(x, y, 3, 3, false);
ChooseOption(x, y, 'All');
Result := True;
if (Result = True) then
begin
LoadsNum := LoadsNum + 1;
LoadsNumB := LoadsNum + 1;
end;
end;
CloseBank;
wait(127 + random(278));
MakeCompass('N');
end;
end;
{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Main loop <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

procedure SetupScript;
begin
Signature;
SetupSRL;
DeclarePlayers;
ActivateClient;
end;

///////////////////////////////////////////////////////////////////////////

begin
SetupScript;
repeat
WalkToWillow;
ChopIt;
WalkToBank;
BankIt;
if(LoadsNumB=Loads)then
begin
NextPlayer(True);
LoadsNumB:=0;
HighestAngle;
MakeCompass('N');
Writeln('Switched players successfully :)');
end;
JADProggy;
until (False);
end.

OK, now here we go with the explaining.

The Setup of a script


Now, for the introduction I have:

{//-----------------------------------------------------------------------------\\
This script will chop willows at edgevil bank. Start ALL active players
at edgevil farthest east bank slot. Axes weilded or un weilded. This script
does NOT feature axe head finding, Will add soon. Do setup and do setup for
DeclarePlayers on lines 28-68. Please remember to post proggies where you
got this script :) Happy autoing!
//------------------------------------------------------------------------------\\}


Now, this is very simple, yet important when making a script. Always have something at the beginning of your script that is very neat that says what to do for the script to run properly, and warnings on what the script doesn't have. And of course, you can make requests for proggies to be posted on your script :)

Also note that every new function/procedure in the whole script has comments that tell you what its doing, to make it easier to read through and get to what your looking for.

Now for the setup, heres what we have:

const
//------------------------------------------------------------------------------\\
//-------------------------------> Setup <--------------------------------------\\
//------------------------------------------------------------------------------\\

DirTorun = 'N';
Loads = 10; //Loads to do before switching players.

//------------------------------------------------------------------------------\\
//----> Auto Colors Only set these if the script is not finding the Willow <----\\
//------------------------------------------------------------------------------\\

WillowColor = 5398624; //Color of willow tree on Main Screen
WillowColorB = 3174496; //another color of willow on Main Screen
WillowColorC = 4293865; //another color of willow on Main Screen

//------------------------------> End Setup <-----------------------------------\\

// DO NOT TOUCH THESE! \\
var GrassColor, GrassBMP, BankBMP, GBankColor, Tries, Willow: Integer;
EntCount, LoadsNum, LoadsNumB, BushWater, BushWaterColor: Integer;
DidRandomHappen: Boolean;
// \\

Now we have the constants. Direction to run and loads to do before switching players (We'll talk about that later)

Its important to tell the user in comments where the setup is at and where it ends. And if you are using auto colors for the tree as we are here, I'd suggest putting comments between what the user needs to setup, and what the user could setup if the current colors aren't working.

As for the variables, I just had those there after the constants and told the user not to touch them. We will talk more about how I used those in the script later. Moving on..

Declare Players array.

Heres what we have:

{************************************************* *************************

----------> Setup Players here <----------

************************************************** ************************}

procedure DeclarePlayers;
begin
HowManyPlayers := 6; //Number of PLAYERS. active or not.
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0; //Player to start on.

//set all user names, passwords and nicks correctly please.

Players[0].Name := 'Jadseven';
Players[0].Pass := 'Password';
Players[0].Nick := 'dsev';
Players[0].Active := True;
Players[0].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot

Players[1].Name := 'UserName';
Players[1].Pass := 'Password';
Players[1].Nick := '3-4 letters of UserName';
Players[1].Active := False;
Players[1].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot

Players[2].Name := 'UserName';
Players[2].Pass := 'Password';
Players[2].Nick := '3-4 letters of UserName';
Players[2].Active := False;
Players[2].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot

Players[3].Name := 'UserName';
Players[3].Pass := 'Password';
Players[3].Nick := '3-4 letters of UserName';
Players[3].Active := False;
Players[3].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot

Players[4].Name := 'UserName';
Players[4].Pass := 'Password';
Players[4].Nick := '3-4 letters of UserName';
Players[4].Active := False;
Players[4].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot

Players[5].Name := 'UserName';
Players[5].Pass := 'Password';
Players[5].Nick := '3-4 letters of UserName';
Players[5].Active := False;
Players[5].Boolean1 := False; //Is Axe equiped? if not then put in FIRST inv slot
NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
end;

{ don't touch below unless you know what your doing! }

Take a look at the bottom of that. I have don't touch below unless you know what your doing in comments. I'd suggest putting that so the user knows its time to stop setting up and start the script :)

Then we have the Declare Players procedure. Now, the HowManyPlayers is How many players there are Active or not. If the script has 6 players (like here) and only 2 of those 6 are active, the HowManyPlayers still ='s 6 as you may already know.

Then we have the player arrays, the user name, password and nick name are used for the multiplayer which the user sets up so that when it goes to next player (if the next player is active) it will type in that user name + pass.

the
NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
Is in the Glossary so if you don't know about that, look it up :)

In this, I have user name Jadseven and nick is dsev. It creates a bitmap mask of dsev and when somebody pops up and says Jadseven it knows to talk to that person in the randoms procedure (which he haven't gotten to yet, we'll talk about that in a minute) Moving on..

The signature

Well, this will be short lol :P and you should know how to do this. we have:

procedure Signature;
begin
ClearDebug;
writeln(' JAD willow chopper by yours truely:');
writeln(' __________ /\ ______ ');
writeln(' |__________| / \ | ____ \ ');
writeln(' | | / /\ \ | | \ \ ');
writeln(' ___ | | / /__\ \ | | \ \ ');
writeln(' \ \| | / /____\ \ | | / / ');
writeln(' \ | / / \ \ | |___/ / ');
writeln(' \____|/ / \ \|______/ ');
wait(3000 + random(750));
end;

This may not look like it says JAD on SRL forums because the spaces between text is kind of weird, but if you paste that into SCAR, it will say JAD in the procedure.

and later in the main loop, it will Writeln this, and wait a little over 3 seconds so the user has time to read your signature which you wasted so much time on lol.

Random Finding

Now, heres what we have:

{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Random Finding <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

function FindFastRandoms: Boolean; //By WT-Fakawi.
var
i: Integer;
begin
for i := 1 to 8 do
begin
case I of
1: if FindDead then
Result := True;
2: if FindMod then
Result := True;
3: if FindMime then
Result := True;
4: if FindMaze then
Result := True;
5: if FindQuiz then
Result := True;
6: if FindDemon then
Result := True;
7: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
end;
7: begin
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Logout;
Exit;
end;
end;
8: RC;
end;
wait(1);
end;
if (Result = true) then
DidRandomHappen := true;
end;

///////////////////////////////////////////////////////////////////////////

procedure FindRandoms;
begin
FindFastRandoms;
FindNormalRandoms;
if (FindNormalRandoms) then
DidRandomHappen := true;
end;

The FindFastRandoms is NOT by me, that is by WT-Fakawi and it is used in a lot of peoples scripts :) although, if you use this in your script, don't think all your work is complete. this only checks for the things that FindNormalRandoms doesn't like mods, mime...etc.

Now in the FindRandoms; procedure, we call for FindFastRandoms, we don't call for it in the main loop, we just call for FindRandoms; which calls for FindFastRandoms because thats in that procedure :p

then we have FindNormalRandoms; this does Not solve the un solvable randoms called scape runes (evil bob...etc) FindFastRandoms looks for that though and logs out if it finds those. To learn more about FindNormalRandoms, look it up! :p

I then have

if(FindNormalRandoms) then
DidRandomHappen := true;

This just says if it finds normal randoms, then it makes that variable I declared above = true. Then in my chopping logs procedure, if it found a random, it doesn't keep waiting for the tree to be gone, instead, it solves the random then clicks the tree again (We'll get to that later once again) Moving on..

Progress report

Heres what we have:

{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> JAD Proggy <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

procedure JADProggy;
begin
ClearDebug;
Writeln(' Please Check out + register on me and pwnaz0rs forums at: ');
Writeln(' Uberbroproductions.net/forums ');
Writeln('[]=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ');
Writeln('|| JAD Progress report. Please remember to post ');
Writeln('|| proggies/bugs wherever you got this script :) ');
Writeln('[]-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ');
Writeln('|| Worked For : ' + ScriptTime2(2));
Writeln('|| Did ' + IntToStr(LoadsNum) + ' Loads ');
Writeln('|| Avoided ' + IntToStr(EntCount) + ' ents ');
Writeln('||=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ');
Writeln('||Thanks for using JAD Willow, happy autoing :) ');
SRLRandomsReport;
end;

First of all, this just says to check out me and pwnaz0r's awesome forums (which you should too :p) and then it says to post progress reports.

the Worked For : ' + ScriptTime2(2)); can always be used to check for how long the script has been going, and in this case, it writes in the debug of course how long its been going.

then it says how many loads it did. and how many ents it avoided. It displays this by how we added to the variables LoadsNum and things like that in the banking procedure. each time it banks, it adds 1 to LoadsNum and then it writes in the debug loads number.

Same for ent; each time it finds an ent, it adds 1 to ents and writes it in the debug.

Then we have SRLRandomsReport. To learn about that, look it up! :p Moving on..

Walking to the willow from bank

Now, heres what we have:

{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Walking to Willow <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

procedure WalkToWillow;
begin
MakeCompass('N');
GrassBMP := BitmapFromString(8, 10, 'z78DA33333177357433A' +
'335E9483439D8D4E3275D2D0CD1C841A61E006F046F69');
BushWater := BitmapFromString(1, 1, '183D00');

BushWaterColor := AutoColorThis(BushWater, 50, MMX1, MMY1, MMX2, MMY2);
RadialWalk(BushWaterColor, 75, 105, 70, 2, 2);
wait(6000 + random(1500));
Flag;
Wait(200 + random(100));
Tries := 0;
repeat
if(Tries = 40)then
begin
Writeln('Could not find willow... :( terminating script..');
TerminateScript;
end;
wait(300 + random(150));
Tries := Tries + 1;
until (FindColorTolerance(x, y, WillowColor, 160, 97, 410, 340, 3)) or
(FindColorTolerance(x, y, WillowColorB, 160, 97, 410, 340, 3)) or
(FindColorTolerance(x, y, WillowColorC, 160, 97, 410, 340, 3));
end;

First of all, we make the compass face north so the walking doesn't get screwed up.

We Auto colorize the BushWaterColor so that we can radial walk using that color properly. Look it up if you don't know about AutoColorThis, because this is one of the most important things used for map walking.

note: This script does not use the GrassBMP yet, I had it in there because new version is going to use it.

So I took a bitmap of the BushWaterColor which is near the willow. It is the bush next to it with a little water in the bitmap so it doesn't click just any old bush :P

then you have BushWaterColor := AutoColorThis(BushWater, 50, MMX1, MMY1, MMX2, MMY2);

AutoColorThis picks the color from the bitmap BushWater, and saves it to BushWaterColor. I made the max tolerance 50, and it looks for it on the MM (mini map) because we have MMX1, MMY1...etc. which looks for things on the mini map of course.

Then we have it radial walk using the BushWaterColor which we auto colored.

I have it wait around 6 seconds after it clicks because the player kind of needs to walk back wards if you've ever been at the bank in edgevil, and when it walks backwards, the flag disappears for a minute, then re appears. if I didn't have it wait before waiting for the Flag to leave using the command Flag; (which just waits until the flag is gone) it would think the flag is gone when it really isn't.

Then I make the variable tries = 0. then the script repeats waiting about half a second until it finds the color of the willow color, but if it waited half a second for 40 times (20 seconds roughly) it will terminate the script because it did not click next to the willow. Moving on..

Walking to the bank from the Willow tree

Now heres what we have:

{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Walking to Bank <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

procedure WalkToBank;
begin
if (InvFull) then
begin
MakeCompass('N');
BankBMP := BitmapFromString(7, 7, 'z78DAB370B430B230B0' +
'00938E469616966698A4B993B9B1B991050D54228B20EB422 6078' +
'34A00FBA54003');
if (not (FindBitmap(BankBMP, x, y))) then
begin
Mouse(627, 88, 8, 8, true);
Flag;
end;
GBankColor := AutoColorThis(BankBMP, 50, MMX1, MMY1, MMX2, MMY2);
RadialWalk(GBankColor, 270, 290, 68, 2, 2);
Flag;
wait(200 + random(100));
end;
end;

now in this, if the inventory is full, it will do the rest of the procedure.

We Make the compass north, then we use the ground of the bank as a bitmap. The reason we don't just make it click the symbol of the bank is because half the time, the symbol isn't on the mini map.

if it doesn't find the bitmap of the ground of the bank, then it clicks a little east using Mouse with random pixels 8 by 8. This is a great fail safe in case it doesn't find the ground of the bank from what side of the willow its on.

Then it Flag;'s. Look it up if you don't know about flag :p

Then we have the normal thing like we did in the walking to the willow procedure which auto colors the Bank Bitmap, GBankColor is the variable of the color for the bank ground, it walks to it with radial walk, waits for flag to be gone, and does a little random waiting. Moving on..

Chopping the willow

Now heres what we have:

{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Willow Chopping <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

function ChopIt: Boolean;
begin
repeat
if (not (LoggedIn)) then
Exit;
if (FindColorTolerance(x, y, WillowColor, 160, 97, 516, 209, 3)) or
(FindColorTolerance(x, y, WillowColorB, 160, 97, 516, 209, 3)) or
(FindColorTolerance(x, y, WillowColorC, 160, 97, 516, 209, 3)) then
begin
MMouse(x, y, 3, 3);
if (IsUpText('illow')) then
begin
Mouse(x, y, 2, 2, true);
repeat
if (InvFull) or (PopUp('ontinue')) then
Exit;
if(DidRandomHappen = true) then
begin
DidRandomHappen:=False;
Mouse(x, y, 2, 2, true);
end;
FindRandoms;
SleepAndMoveMouse(9671 + random(1709));
FindRandoms;
until (not (FindColorTolerance(x, y, WillowColor, 160, 97, 410, 340, 3))) or
(not (FindColorTolerance(x, y, WillowColorB, 160, 97, 410, 340, 3)))or
(not (FindColorTolerance(x, y, WillowColorC, 160, 97, 410, 340, 3)));
repeat
if (InvFull) or (PopUp('ontinue')) then
Exit;
if(DidRandomHappen = true) then
begin
DidRandomHappen:=False;
Mouse(x, y, 2, 2, true);
end;
wait(750+random(250));
FindRandoms;
until (FindColorTolerance(x, y, WillowColor, 160, 97, 410, 340, 3)) or
(FindColorTolerance(x, y, WillowColorB, 160, 97, 410, 340, 3)) or
(FindColorTolerance(x, y, WillowColorC, 160, 97, 410, 340, 3));
Result := True;
end;
end;
until (InvFull);
end;

First of all, we check if the player is logged in, if no player is logged in, then it exits.

Then, if it finds 1 of 3 colors of the willow which we put in the constants, it Moves the mouse to the willow (hopefully lol), Looks for the text illow and clicks there if that text is up.

then it begins waiting until the willow is gone. there are a lot of fail safes in there in case something happens while its waiting. for fail safes we have:

if the inventory is full before it chops down the tree, or it finds the pop up continue (level up) then it exits.

if the variable DidRandomHappen ='s true (as we had in the randoms procedure) then it clicks the willow again, and makes DidRandomHappen= false so it doesn't always think a random happens while chopping which would be a huge problem.

Now those are all some pretty good fail safes to ensure that chopping goes smooth.

Then it does the FindRandoms procedure. It repeats Sleeping and moving the mouse until it doesn't find the willow colors(AKA the tree is gone).

Then it repeats waiting around 1 second and does random checking until it finds the willow again. then it keeps repeating all these things until the inventory is full, then it does the walk to bank procedure which we talked about above. Moving on..

Depositing the willows into the bank

Now heres what we have:

{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Banking Willows <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

function BankIt: Boolean;
begin
if (InvFull) then
begin
Willow := DTMFromString('78DA63FCC4C4C0D0C9C8800A1819FE83490 68' +
'6FF40C0C8C08C550D8204D2AC40355308A86104AA994940CD 37A0' +
'7BE61050F31AA8A68F0835B3F0AB010040990CF0');
MakeCompass('S');
wait(250 + random(167));
OpenBankQuiet('eb');
Flag;
wait(500 + random(267));
FixBank;
if (FindDTM(Willow, x, y, 568, 209, 742, 460)) then
begin
Mouse(x, y, 3, 3, false);
ChooseOption(x, y, 'All');
Result := True;
if (Result = True) then
begin
LoadsNum := LoadsNum + 1;
LoadsNumB := LoadsNum + 1;
end;
end;
CloseBank;
wait(127 + random(278));
MakeCompass('N');
end;
end;

OK, so if the inventory is full, it does everything else in the function.

So I made a willow DTM, and did all that stuff you need to do for a DTM as you would know if you looked it up! :p

Now for the banking we make the compass south because thats better for finding the bank for this particular bank.

Then we open the bank quietly, while its walking to the bank booth we have it Flag; , and wait about half a second.

Now we Fix the bank, look for the Willow DTM in the coordinates I made for the inventory, and then it right clicks the willow, chooses option All (Deposit All) then the result=true (of the function)

if the result ='s true, we have LoadsNum=LoadsNum + 1; and LoadsNumB=LoadsNumB + 1; The reason we have 2, is for when we switch players, we want the script to check if the loads is at whatever the user sets loads too.

lets say for example the user sets the loads to 10. Once the script gets to 10 loads, its not ever going to = 10 loads again after switching players, so we need to make it start over with the loads counting.

so in the main loop (we are getting kind of a little ahead) we have it make LoadsNumB = 0 again. The reason we have LoadsNum then, is because we still want it to display our progress report with the correct number of loads for all charactors.

Then we Close the bank, wait a very little amount of time then make the compass north again for walking back to the willow and repeating. Moving on..

The Main loop (includes multi player)

Now heres what we have:

{/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

----------> Main loop <----------

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/}

procedure SetupScript;
begin
Signature;
SetupSRL;
DeclarePlayers;
ActivateClient;
end;

///////////////////////////////////////////////////////////////////////////

begin
SetupScript;
repeat
WalkToWillow;
ChopIt;
WalkToBank;
BankIt;
if(LoadsNumB=Loads)then
begin
NextPlayer(True);
LoadsNumB:=0;
HighestAngle;
MakeCompass('N');
Writeln('Switched players successfully :)');
end;
JADProggy;
until (False);
end.


Now take a look at the setup for the script. We have that there so our main main loop looks more neat and we don't need that all in there, we can just call for SetupScript. Then we have our main loop.

after it sets up the script, it repeats walking to the willow, chopping the willow, walking to the bank and banking the willows.

Then, if LoadsNumB = Loads the user set, then it switches players and make LoadsNumB = 0 again, makes user at highest angle, Makes compass North, Writes in the debug that you switched players.

Then after that, we have it do JADProggy, and in the JADProggy procedure, we have it clear the debug so that each time we display a progress report, the only one there is the fresh one and not the past ones which are of no use now. it does all that until the user stops it manually.


Well thats it. this tutorial took me a long time so please feel free to post comments/feed back/suggestions on it. Thanks :)

XcanadamanX
04-11-2007, 11:51 PM
nice but is this really a tut for advanced?

JAD
04-11-2007, 11:52 PM
Whoops, didn't mean to post it here. Mod/Admin, please move to intermediate tuts unless you think this is a beginner tut lol :p Thanks for the comment though canada.

legendaryhero90
04-12-2007, 12:02 AM
should be for beginners

JAD
04-12-2007, 12:18 AM
should be for beginners

Are you serious? Read some beginner tutorials. What do they teach you? MoveMouse, MoveMouseSmooth, ClickMouse, Writeln....etc. I think this should be in the intermediate section because this may look like a whole different language to a beginner scripter. Theres a tutorial called Adding randoms to your scripts by white shadow, thats in intermediate section. this talks about more then just randoms :p whatever the admins/mods think though.

Smartzkid
04-12-2007, 12:31 AM
Nice tut...I think it covers alot of stuff from both beginner (siggy's and stuff) and from intermediate (mostly everything else)

I like it, but it seems kinda hard to read those long paragraphs...not sure what you could do to help it, maybe try bolding/underlining important stuff...

IEatJ00erBaybees
04-12-2007, 12:31 AM
Great Guide JAD! Only problem..I don't think I can remember all these codes and the order in which you put them.

if(DidRandomHappen = true) then
begin
DidRandomHappen:=False;

I didn't know you had to do that..I think it may just be too much for me. I'll keep hitting at it, until someday, I can create my own script. But I don't know about now...

JAD
04-12-2007, 12:55 AM
if(DidRandomHappen = true) then
begin
DidRandomHappen:=False;
Mouse(x, y, 2, 2, true);
end;

the reason you need the then begin there is because theres more then 2 things you want it to do after the then if DidRandomHappen = true. if there was only 1 thing, like:

if(DidRandomHappen = true) then
begin
DidRandomHappen:=False;
end;

then it would only need to be like this:
if(DidRandomHappen = true) then
DidRandomHappen:=False;

a then grabs the line after it, and nothing else. so if the line under it is a begin, then it will do everything between that begin, and the end.

The reason this may seem hard to understand, is because I'm not giving a full explanation/teaching on how these things work. you should already have a basic idea of radial walking..etc. thats why it should be intermediate in my opinion, because you should know most of this stuff already. I'm going to go back and edit now a lot though to make it more for a beginner to understand a little bit. Thanks for the comments guys.

Edit: Fixed a few grammar errors, and made it a LOT more readable (hopefully). Take a quick look at it now, should be easier on the eyes :)

IEatJ00erBaybees
04-12-2007, 07:30 PM
Noooooooooooooo..I mean I get it and everything, but I won't remember it.

~alex~
04-12-2007, 08:06 PM
Noooooooooooooo..I mean I get it and everything, but I won't remember it.
Just stick at it, it will come eventually.

Nice tut JAD, a hell of alot of info there.

JAD
04-12-2007, 09:08 PM
Noooooooooooooo..I mean I get it and everything, but I won't remember it.

Well, you will remember it, but it takes time :) I don't remember 100% of the things in my scripts, most of it I do, but what I do is when I'm making a new script, I look back at that one and look at what I don't remember. Then, I implement that into my new script, and you get closer and closer to remembering more of it :)

@Alex thanks :) I was hoping it would help somebody (if it even helped you :p)

I'm making a new update to it. Thanks for the feed back guys, still need a mod/admin to move this to intermediate tutorials though! :p

Edit: Huge update! Everybody should look through it again because I just spent over another 2 hours making the Glossary and changing the tutorial to be more helpful :)

IEatJ00erBaybees
04-12-2007, 09:48 PM
Well, on the bright side, out of Constants, Variables, Procedures, Functions, etc..We're doing Functions in Algebra tomorrow! This is my first year of Algebra I, and when we learned more deeply about variables, it helped my scripting, and I only understand Functions a little bit! :P So, woot? :P

What we really need is an SRL Guide. No like, an in depth one. Not just one that tells you what to do..but also how to implement it into your script.

Like, do you list variables in SRL on your scripts? Or are they part of the next function/procedure?

****!!!!!!!!!!!! I had a 200 line script going!!! And I lost half of it because friggan SCAR didn't respond!

JAD
04-13-2007, 12:31 AM
Well, on the bright side, out of Constants, Variables, Procedures, Functions, etc..We're doing Functions in Algebra tomorrow! This is my first year of Algebra I, and when we learned more deeply about variables, it helped my scripting, and I only understand Functions a little bit! :P So, woot? :P

What we really need is an SRL Guide. No like, an in depth one. Not just one that tells you what to do..but also how to implement it into your script.

Like, do you list variables in SRL on your scripts? Or are they part of the next function/procedure?

****!!!!!!!!!!!! I had a 200 line script going!!! And I lost half of it because friggan SCAR didn't respond!

list variables in SRL on your scripts? Sorry, don't get what you mean by that. And did you read the new version yet? You should, may help you learn more :p

and if you think about it, showing you how I used IsUpText, Mouse...etc in my script will help people learn how to put it in there script, because they will think "Oh, master/uber scripter JAD says MMouse, check for text then click. I'll try that! JAD is awesome! I should go register on his forums and have everybody else do the same!" They'd be thinking something like that, maybe with more compliments towards me lol! :p But if you get how I used them in the script, you should be able to use it in your own. How do I open a bank and close it? "Well, master/uber scripter JAD says use OpenBankQuiet because that has no weird mouse movements, and to close the bank I use CloseBank; Gosh JAD's cool!" lol :p

Ashur2Good
04-13-2007, 02:34 AM
Very nice tu! :), this shoudl be for intermediates though, but still exlain's everything you need for a good script :D.



very nice :D-ashur:stirthepot:

Ejjman
04-13-2007, 02:41 AM
The use of the almighty progress report. (which every good script should have)


At the beginning of the thing, you put this. Your tut. I disagree with the 'every good script should have' part. Sure, its nice to have, but still a bad opinion IMO :P:P

arti
04-13-2007, 03:22 AM
Nice tutorial. I enjoyed reading this ... makes me want to take apart my script =\

Thanks for the information. Very helpful!

JAD
04-13-2007, 03:45 AM
At the beginning of the thing, you put this. Your tut. I disagree with the 'every good script should have' part. Sure, its nice to have, but still a bad opinion IMO :P:P

Lol :p I'll put a 'In my opinion in there' :p thanks :p But did you like the tut Ejj? I need the almight ejj's oppinion :p

@Arti and ashure, thanks for the comments :) Glad to be of help

Rune Hacker
04-13-2007, 04:04 AM
I like how you explained everything so it made sense, i already knew it though, but it helps others. I still like the SRL Manual the best though, but i wish they would go into a little more detail about all the procedures. Still, good job JAD. Incase anyone wanted the manual also, its in the Download SRL section and below on the attachment. Still, good job JAD.

JAD
04-13-2007, 01:48 PM
I like how you explained everything so it made sense, i already knew it though, but it helps others. I still like the SRL Manual the best though, but i wish they would go into a little more detail about all the procedures. Still, good job JAD. Incase anyone wanted the manual also, its in the Download SRL section and below on the attachment. Still, good job JAD.

Thanks Rune Hacker :) I found that too with the SRL manual that it doesn't explain everything that great. I get almost everything in the SRL manual now that I'm more advanced, but still, not everything ;). The reason I thought this tutorial would be helpful, is because it shows everything there is to making a script (Well, most types of scripts anyways.) So I thought it would help people that already knew most of the commands that it uses, learn to make there own scripts. Or, even if they didn't know the commands, thats why I added the glossary :)

ronny.m.p
04-14-2007, 07:44 PM
This is nice but you should add more on Multi Player stuff.


EDIT: You should always put:

if (LoggedIn = false) then NextPlayer(false);

at the end.

JAD
04-14-2007, 11:01 PM
I have NextPlayer(True) if it does specified number of loads.. :p And I could talk about multi player, I may do that some more, thanks!

ronny.m.p
04-15-2007, 04:49 PM
I know how to do multi-layer scripts but alot of people have been posting in scripting help about it..just an idea ;)

omfg2007
04-15-2007, 07:51 PM
This deserves a sticky any one who takes the time to explane a script and make it easy to see how to use them and explane it al is what all beginers need.exelnty work and good idea!:spot:

JAD
04-15-2007, 11:08 PM
This deserves a sticky any one who takes the time to explane a script and make it easy to see how to use them and explane it al is what all beginers need.exelnty work and good idea!:spot:

Thanks a lot! I was hoping I'd help a few people :D

lilboy543
04-20-2007, 05:58 PM
I think i get it. would the commands below click on a willow tree?
Why/why not?
if (FindColorTolerance(x, y, WillowColor, 160, 97, 516, 209, 3)) or
(FindColorTolerance(x, y, WillowColorB, 160, 97, 516, 209, 3)) or
(FindColorTolerance(x, y, WillowColorC, 160, 97, 516, 209, 3)) then
if (IsUpText('illow')) then
mouse(x,y,2,2);

JAD
04-20-2007, 09:50 PM
It would if you have a MMouse(x,y,2,2) before the IsUpText. because that checks for the text in the top left corner willow, and if its there, it will click. So of course, you need to move the mouse to the tree first, or that text wouln't be up ;). Heres how the part after the if(FindColor should look like (almost like you had it)

MMouse(x,y,2,2);
if (IsUpText('illow')) then
mouse(x,y,2,2,true);

As for the mouse, you just missed a true. True for left click, false for right. The willowcolor, WillowColorB...etc. are all declared in the constants, so you'd need to do that yourself too.

ronny.m.p
04-22-2007, 07:32 PM
if (FindColorTolerance(x, y, WillowColor, 160, 97, 516, 209, 3)) or
(FindColorTolerance(x, y, WillowColorB, 160, 97, 516, 209, 3)) or
(FindColorTolerance(x, y, WillowColorC, 160, 97, 516, 209, 3)) then
MMouse(x,y,0,0);
if (IsUpText('illow')) then
mouse(x,y,0,0);

Don't have any randomness on your Mouse; because it will set of jajex detction if you move the mouse one spot then click another..only use rx and ry if you dont have a MMouse before it.

JAD
04-23-2007, 12:47 AM
Don't have any randomness on your Mouse; because it will set of jajex detction if you move the mouse one spot then click another..only use rx and ry if you dont have a MMouse before it.

Are you talking to me?? There is nowhere in my script at all where I do not use random parameters for moving and clicking the mouse..

Dan Cardin
04-23-2007, 09:01 PM
really really helpful got me through my first script and...well really well put together

JAD
04-23-2007, 09:54 PM
really really helpful got me through my first script and...well really well put together

Thanks a lot for posting dan :D Glad to be of help to a fellow scripter.

Fearlesssss
05-02-2007, 12:59 PM
I always wonderded how to let my char wait until the willow is gone. This was the best tutorial ever!!!!!!!! w0000000000t :D:D:D Go on like this man!:D

Fearlesssss

JAD
05-02-2007, 02:01 PM
I always wonderded how to let my char wait until the willow is gone. This was the best tutorial ever!!!!!!!! w0000000000t :D:D:D Go on like this man!:D

Fearlesssss

Thanks a lot! :D You should also read my tutorial on learning the things to become a SRL member. That may teach you a few things too ;)

lordsaturn
05-30-2007, 05:29 AM
JAD....you're fucking incredible.

Thank you so much for all your hard work and all you've contributed to this community.

Especially this guide!

JAD
05-30-2007, 03:26 PM
JAD....you're fucking incredible.

Thank you so much for all your hard work and all you've contributed to this community.

Especially this guide!

WOW! Thanks a LOT! :D Best remark I've gotten off of a tutorial :p

Scarf4ce
06-05-2007, 06:26 AM
This helped me understand a lot of procedures that go into scripts and helped me make my own power chopper. I really liked your idea to add a glossary. Thanks.

JAD
06-05-2007, 02:13 PM
This helped me understand a lot of procedures that go into scripts and helped me make my own power chopper. I really liked your idea to add a glossary. Thanks.

Very glad that it helped you! :) Can't wait to see your new script all finished.

kemico2
06-07-2007, 06:30 AM
This is what i have been looking for for a long time, A tutorial that has many of the cominly used functions and explains how to use them. Thank you very much JAD this is probally my most read tutorial and it has help make my first script.

JAD
06-07-2007, 02:30 PM
This is what i have been looking for for a long time, A tutorial that has many of the cominly used functions and explains how to use them. Thank you very much JAD this is probally my most read tutorial and it has help make my first script.

Awesome! :) Glad to hear it. You all might want to check out Learning the things to become a SRL member after this, because that teaches you about the same things and more.

x13om13e12x
06-17-2007, 05:23 PM
I Started learning scripting and you helped me out so much with your TUTs and I learned so much from all your scripts. I'm in the middle of my first script which kills cows and banks cow hides in lumbridge

JAD
06-17-2007, 05:51 PM
I Started learning scripting and you helped me out so much with your TUTs and I learned so much from all your scripts. I'm in the middle of my first script which kills cows and banks cow hides in lumbridge

Awesome! Glad to hear it. And I hope to see your new script coming out soon! :)

Inf456
06-18-2007, 09:01 PM
Wow dude this is great. All your tuts help me A LOT! I have gone from having a powerchopper be my first script, didn't finish it, to a Fally yew chopper, didn't finish, and now I am officially sticking with a Draynor Oak Banker as being my first script. I rated 5 stars.

JAD
06-18-2007, 10:26 PM
Wow dude this is great. All your tuts help me A LOT! I have gone from having a powerchopper be my first script, didn't finish it, to a Fally yew chopper, didn't finish, and now I am officially sticking with a Draynor Oak Banker as being my first script. I rated 5 stars.

Great! Thanks a LOT! :D

sheetomg
06-21-2007, 12:10 AM
thx helped me alot understand certain procedures

JAD
06-21-2007, 01:56 AM
thx helped me alot understand certain procedures

np :) And glad to hear it!

randy marsh
06-21-2007, 10:29 PM
Good guide read it all twice just to make sure i remember it all!

JAD
06-21-2007, 11:51 PM
Good guide read it all twice just to make sure i remember it all!

Thanks a lot! :D And yeah, when I started reading tutorials I read them like 4 to five times, and would read the things I didn't get 100% over a LOT and test around with it :p

Macho Man67
06-29-2007, 08:54 PM
Nice tutorial JAD! This helped me with my powerchopper. Also this helped me understand how to radialwalk without a road( I also read your tutorial about SRL member things):D. But awesome job JAD(*Crowd starts to cheer*)!!!

JAD
06-29-2007, 09:07 PM
Nice tutorial JAD! This helped me with my powerchopper. Also this helped me understand how to radialwalk without a road( I also read your tutorial about SRL member things):D. But awesome job JAD(*Crowd starts to cheer*)!!!

Thanks a lot! :D

zenma
06-29-2007, 11:29 PM
Nice tut. i learned what a few more commands do :)

Fizzi
06-30-2007, 01:42 AM
Great tutorial! I learn best from example so this was perfect for me. Since I have a background in programming (I did Java and VB in school), I kinda just skipped right to this, barely looked at the beginner tuts.

Anyway, thank you so much this helped me greatly.

JAD
06-30-2007, 03:45 AM
Thanks guys :)

plaxlord
07-24-2007, 05:52 AM
rly good tut :)

i'm just having trouble with raidial walk



program New;
{.include SRL\SRL.scar}
begin

RadialWalk( 6250343 , 345, 371, 27, 2, 2);
//RadialRoadWalk(RoadColor, 345, 371, 27, {Xmod}, {Ymod});

end.

it doesnt click anywere on the minimap :( debug box says
Successfully compiled
Successfully executed

( have scar 3.11 and div 3.81( not shroe on div but its lastest one)

can u plz help?

gillian
02-22-2008, 08:08 PM
This is a serious grave dig (sorry Admins!!), but I wanted to thank JAD .. you wouldn't believe how much you just clarified for me simply by posting definitions :) I'm sure some of it is obsolete now, but it was immensely helpful.

Thanks! :D

Torrent of Flame
02-23-2008, 03:52 PM
Helping me out alot :D

warrior786
07-16-2008, 10:16 PM
Hey bro, this is a great great tut!!! i wanted a tut like this which explains how an actual script works rather than just bits and pieces...
thanks once again!!learned alot!

RavenE
10-21-2008, 01:57 AM
Great Guide JAD! Only problem..I don't think I can remember all these codes and the order in which you put them.

if(DidRandomHappen = true) then
begin
DidRandomHappen:=False;

I didn't know you had to do that..I think it may just be too much for me. I'll keep hitting at it, until someday, I can create my own script. But I don't know about now...

No offence or anything but nice try with rendering your signature. lol look at the compressor on the end of the barrel PLEASE NOTE: NO OFFENSE!