PDA

View Full Version : How to set up a script



Awkwardsaw
07-05-2009, 04:17 AM
this is my second tut, and this time i will be teaching you how to set up the base of the script :D. lets get goin!

Set up SRL

the first thing you need to do is set up srl. i saved this as my defualt script for scar:

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

how you save it as default is go to file > save as default, and that will load every time you open a new tab or open scar.

doing this saves a lot of time, and very usefull if you cant remember what to type in to include srl: {.include SRL/SRL.scar} (like me :p)

Coming up with the plan

for this i will use a lumby flax spinner as an example. what you do is you make a few little comment brackets so you can write down what you want to do with the script.

{ bank
go to room
go to bank
spin
progress report
}
program LumbyFlaxer;
{.include SRL/SRL.scar}
begin
setupsrl;
end.

this is a reminder of every thing that i want my script to do, which is bank, get to the flax room, spin, get to bank, and bank again. along with the basics of anti ban, anti random, and a progress report.

next, we will go even more precise, coming up with ways to do what you want to do, like so:

{ bank
-need to bank
-find bank
-find banker


go to room
-go to stairs
-go to second floor
-check door

go to bank
- get to stairs
- get to top floor

spin
- find wheel
- check flax
- check bow strings
- wait while spinning

progress report
- time running
- bow strings strung
- flax to go
- exp gained
- money gained
- crafting lvl
- exp to go till next lvl
}
program LumbyFlaxer;
{.include SRL/SRL.scar}
begin
setupsrl;
end.

now that we know exactly what we want, lets get to the procedures

Making the base procedures

before we get to the meat of the procedures, lets get the base ones down first. what i mean is: declare players, set up smart, set up player, next player, and and the anti ban/ randoms.

{ bank
-need to bank
-find bank
-find banker


go to room
-go to stairs
-go to second floor
-check door

go to bank
- get to stairs
- get to top floor

spin
- find wheel
- check flax
- check bow strings
- wait while spinning

anti ban

anti random

progress report
- time running
- bow strings strung
- flax to go
- exp gained
- money gained
- crafting lvl
- exp to go till next lvl
}
program LumbyFlaxer;
{.include SRL/SRL.scar}

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

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;

{Players[1].Name := '';
Players[1].Pass := '';
Players[1].Nick := '';
Players[1].Active := True;}
end;

procedure AntiRandom;
begin
if not LoggedIn then Exit;
FindNormalRandoms;
end;


Procedure AkwardAntiBan;
begin
if not LoggedIn then Loginplayer;
case Random(11) of
0: HoverSkill('Random', false);
1: begin
HoverSkill('Woodcutting',false);
wait(2500+Random(500));
GameTab(4);
end;
2: PickUpMouse;
3: begin
MakeCompass('E');
wait(10+random(5));
MakeCompass('N');
end;
4: begin
setangle(false);
wait(10+random(10));
setangle(true);
end;
5: SleepAndMoveMouse(600000+random(400000));
6: RandomRClick;
7: RandomMovement;
end;
end;

procedure SetUpPlayer;
begin
if not loggedin then loginplayer;
SetAutoingDefaults;
setangle(true);
setrun(true);
end;

procedure NextPlayerP;
begin
Players[CurrentPlayer].Active := False;
LogOut;
NextPlayer(Players[CurrentPlayer].Active);
setupplayer;
end;

procedure MySmartSetup;
begin
writeln('setting up smart');
SMARTSetupEx(100, True, True, False);
SetTargetDC(SMARTGetDC);
end;

begin
setupsrl; //
declareplayers; // this is the script set up
mysmartsetup; //
setupplayer; //

begin //
// this is the part where the script does its thing
end; //
end.

note: antiban and randoms are just an example, ;)

so far, i have SMART load up, log in the player and set him up. lets get teh banking!

Procedures

now, i wont make the actual procedures, since its only an example. they will only be getting the general point across


function needtobank: boolean;
begin
if invfull then result:= true;
end;

function findbank: boolean;
begin
if findsymbol(x, y, 'bank') then result:= true;
end;

function findbanker: boolean;
begin
end;

procedure bank;
begin
end;


keep doing this for the rest of the script, and then get to making the procedures work

theres nothing more to say about this subject, so i'll end the tut here ;)

i wish you good luck with script making, and go ahead and ask questions in this thread, pm me, or contact me on msn: akwardsaw@hotmail.com

also, ideas for the tut would be awesome

~ akwardsaw

TomTuff
08-06-2009, 11:22 AM
+1 rep. maybe add declareplayers and how to call it in the main loop?

Awkwardsaw
08-06-2009, 11:26 AM
oh wow, thanks for reading / bumping :p

i already added declare players and multi players, and usually knowing how to use it is more into failsafes. i can add it in tomorrow though

gn8771
08-24-2009, 11:27 AM
It gives me a: Line 48: [Error] (19870:1): Identifier expected in script
for some reason. Here are the lines where it gives the error:


procedure SetUpPlayer;
begin
if not loggedin then loginplayer;
SetAutoingDefaults;
setangle(true);
setrun(true);
end;

line 48 is the: procedure SetUpPlayer; line.

I don't know why it would be an error.

JAD
08-24-2009, 12:50 PM
It gives me a: Line 48: [Error] (19870:1): Identifier expected in script
for some reason. Here are the lines where it gives the error:



line 48 is the: procedure SetUpPlayer; line.

I don't know why it would be an error.

You are probably missing an end; or something on some code above that. Post a little more code and I can help you if you still can't find it.

Awkwardsaw
08-25-2009, 10:34 AM
yeah, its probobly a mising end in the procedure above it

Sandstorm
09-29-2009, 11:41 AM
Not a bad start, but I think you need to go more in depth on how to create and use the base functions and procedures that you briefly touched on. I also think you should show them how to create and (as you put it) make the procedures work.

For example, instead of saying:


keep doing this for the rest of the script, and then get to making the procedures work

Do something like this:


Build out the rest of the script like this, making procedures and functions based on what you need them to do, and then work on the code. For example, I was creating a Soul Wars script, and made a couple functions and procedures like this:

Function DidIDie : Boolean;
Begin
End;

and

procedure ToPortal(Portal : Integer);
Begin
End

And slowly built them into these next two, which (at the time it was created) worked, from the data I collected while running through the stuff I needed to create it.

function DidIDie: Integer;
begin
Result := 0;
if PointInBox(GetMyPos, IntToBox(1816, 3220, 1823, 3230)) then
Result := 1;
if PointInBox(GetMyPos, IntToBox(1841, 3217, 1843, 3219)) then
Result := 2;
if PointInBox(GetMyPos, IntToBox(1932, 3244, 1934, 3246)) then
Result := 3;
if PointInBox(GetMyPos, IntToBox(1951, 3234, 1958, 3244)) then
Result := 4;
end;

and

procedure ToPortal(Portal: Integer);
begin
if not OutOfGame then
Exit;
case Portal of
1:
begin
if not TileOnMM(Point(60 - 1899, 77 - 3162)) then
WalkToTile(Point(60 - 1890, 77 - 3164), 2, 1);
WalkToTile(Point(60 - 1899, 77 - 3162), 2, 1);
end;
2:
begin
if not TileOnMM(Point(60 - 1880, 77 - 3162)) then
WalkToTile(Point(60 - 1890, 77 - 3164), 2, 1);
WalkToTile(Point(60 - 1880, 77 - 3162), 2, 1);
end;
3: WalkToTile(Point(60 - 1891, 77 - 3163), 2, 1);
end;
end;

Now, the code blocks I posted are probably a bit advanced to place in a beginners tutorial like this, but if you did it with some simpler things, I think it would help a lot. Also, I would like to point out I skipped out a huge part in that example quote, and didn't show how I got from point A to point B - it would help people to understand how to create a procedure that worked if you walked them through it step by step.

It's got potential, I just don't see newcomers understanding it so well, and they are presumably the people you're aiming it at. You're assuming knowledge of code in your bit about telling them to make the procedures, and make them work, when in fact, the person I think that you most want to aim a tutorial like this at (most likely someone who knows how to create a proper, working procedure will already know the basis of a full script) doesn't know much, if anything, about scripting.

I hope this helped, and if you want me to look at anything else, let me know :).

~Sandstorm