Naum
04-15-2008, 02:43 PM
How To Make a Script Run Flawlessly.
This tutorial has some quotes from Chuck Norris, those who are not worthy must NOT look!, Or Fear Death!
Table Of Contents:
I - Beginning Notes.
II - Intoduction.
III - Improvisations.
IV - Failsafes.
V - TimeMarks!!
VI - End Notes.
I - Beginning Notes.
Welcome to NaumanAkhlaQ's tutorial on How To Make a Script Run Flawlessly. SO why did I make this tutorial??
Well a script without Failsafes, , TimeMarks and Improvisation[/i] techniques is like Chuck Norris without his roundhouse kicks. <-- Freaky, no?
Every script needs this criteria for it to run flawlessly. N.B, I believe that there is no such thing a flawless becuase nothing is [u]perfect flawless just means good.
Ok so lets begin!!!
II - Introduction.
SO what are Failsafes, TimeMarks and Improvisations.
Well they are what makes a script run Flawlessly.
Ok that this scenario for instance.
Your right outside the general store and you need to get inside, just one problem your in world 1, and it's really crowded.
What could you do?
http://i28.tinypic.com/2vab887.jpg
No Problem you say just use If FindSymbol(x,y,'store') Then... But how will S.C.A.R manage to find the symbol when there are loads of player dots crowding the symbol???
Chuck Norris says "RoundHouse kick all of them in their Faces!!!" Alas it isn't that easy.
III - Improvisations.
Ok so returning to the problem we encountered in chapter II, what could we use?
Ok SO Our Options:
1: Co-ord Clicking.
2: Color Finding;
3: Make it repeat until it finds the symbol.
Ok so I'll put them in order of non-detectability:
2: Color Finding;
3: Make it repeat until it finds the symbol
1: Co-ord Clicking.
So how can we use them in our script, here is an example:
http://i28.tinypic.com/2vab887.jpg
If (not(FindSymbol(x,y,'store'))) Then
Begin
WriteLn('General Store Not found, Trying another tack');
If FindColorSpiral(x,y,47587,Co-ords here) Then
Mouse(x,y,1,1,true)
FFlag(0)
If (Not(FindColorSpiral( x,y,47587,Co-ords here) Then
WriteLn('Couldnt Find Color, now going to co-ord click')
Begin
Mouse(657,655,5,5,true);
FFlag(0)
If (not(FlagPresent)) Then
WriteLn('We have died')
TerminateScript;
end;
end;
^ Thats Just an example, but hounostly it looks very messy so hows about we put it in a seperate Procedure ^
SO here
Procedure TryAgain;
Begin
WriteLn('General Store Not found, Trying another tack');
If FindColorSpiral(x,y,47587,Co-ords here) Then
Mouse(x,y,1,1,true)
FFlag(0)
If (Not(FindColorSpiral( x,y,47587,Co-ords here) Then
WriteLn('Couldnt Find Color, now going to co-ord click')
Begin
Mouse(657,655,5,5,true);
FFlag(0)
If (not(FlagPresent)) Then
WriteLn('We have died')
TerminateScript;
end;
end;
Procedure FindStore;
Begin
If (not(FindSymbol(x,y,'store'))) Then
Begin
TryAgain;
Begin
BuyBuckets; //e.t.c if our script hasn't terminated //
end;
end;
end;
That Looks much better and less messier.
Thats that covered, now what about makeing it repeat until it finds the symbol
Well we could do something like this.
If (Not (FindSymbol(x,y,'store'))) then
Begin
Repeat
If FindSymbol(x,y,'store') then
Result := True;
Mouse(x,y,1,1,true);
Until(Result);
FFlag(0);
end;
^ But what if it doesn't find it wouldn't that be a waste of time, that leads us on to the next chapter on FailSafes.
IV - Failsafes.
Ok so scenario 2 - we can't let it keep trying to find it, we need to make it stop after doing ten tries or something...
And Failsafes do exactly that.
So First we make a variable called Tries as an Integer; .
http://i28.tinypic.com/2vab887.jpg
Procedure FindStore;
var
Tries: Integer; <---- Here!!!
Begin
If (Not (FindSymbol(x,y,'store'))) then
Begin
Repeat
If FindSymbol(x,y,'store') then
Result := True;
Mouse(x,y,1,1,true);
Until(Result);
FFlag(0);
end;
end;
OK SO we made an Integer called tries, now what do we do?
One good thing about an Integer as it will always start at 0 unless specified not to. So we can keep adding on one in a loop until it will get to 10 as they say so our code could look something like this:
Procedure FindStore;
var
Tries: Integer; <---- Here!!!
Begin
If (Not (FindSymbol(x,y,'store'))) then
Begin
Repeat
If FindSymbol(x,y,'store') then
Tries:=Tries+1;
Result := True;
Mouse(x,y,1,1,true);
Until(Result) or (Tries = 10);
FFlag(0);
end;
end;
SO what we are doing there is basically telling it to add one onto zero each time until it gets to ten meaning it will try to find then symbol 10 times. so Tries:=Tries+1; is basically 0:=0+1 and it a second time is 1:=1+1; e.t.c
SO what does
Tries = 10
do? What it does is that it will stop after Tries is equal to 10 meaning it will try and find the symbol store until it finds it or it tires 10 times.
Simple huh....
But Chuck Norris isn't impressed, "So wouldn't it time out just as it reaches ten meaning it might not click???".
Well guess what folks Chucks right again!!!
Procedure FindStore;
var
Tries: Integer; <---- Here!!!
Begin
If (Not (FindSymbol(x,y,'store'))) then
Begin
Repeat
If FindSymbol(x,y,'store') then
Tries:=Tries+1 <--// Will stop here! if it finds it the tenth time//
Result := True;
Mouse(x,y,1,1,true);
Until(Result) or (Tries = 10);
FFlag(0);
end;
end;
So it should look like:
Until(Result) or (Tries > 10);
Becuase when its over ten meaning it will stop after it's clicked the symbol. Thats about all and you can use it if you want to repeat a procedure so you could do (Just for Chuck Norris' pleasure
Repeat
DoRoundHouseKicksOnBadGuys;
i:=i+1;
Until(i> 6{Number Of Bad Guys!})
SO there we go we have made a working Failsafe whilst satisying Chuck Norris :)
V - TimeMarks!!
Ok SO what are TimeMarks?
Well stupid Question lets ask the all knowing Chuck.
Chuck Norris says: "Some code used in a script to make a loop stop after a certain amount of time";
Ok How you use time marks is just declare them a variable first ok lets do Chuck Norris as an Integer.
N.B You must declare the
MarkTime
Before the loop begins.
Example (this would be wrong):
Procedure Chuck;
var Chuck_Norris : Integer;
Begin
Repeat
MarkTime(Chuck_Norris)
Until(TimeFromMark(Chuck_Norris) > (8000))
^That would be wrong as it will start it again from zero so it will never get to 8 seconds, this is what you call an endless loop^
So this would be right:
Procedure Chuck;
var Chuck_Norris : Integer;
Begin
MarkTime(Chuck_Norris)
Repeat
RoundHouseKicks;
Until(TimeFromMark(Chuck_Norris) > (8000))
A good way of reminding you that you should never declare it in a loop is that: Chuck Norris always comes first.
So now you wonder what this does??
Until(TimeFromMark(Chuck_Norris) > (8000))
Well it tells S.C.A.R that it will repeat RoundHouseKicks; for 8 seconds( Not enough time??? Too much time for Chuck Norris.!)
Remember the code that goes Inbetween the brackets must be declared as an Integer!!!.
SO you could use it for something else:
Scenario 3:
Your Mining some coal rocks, with your own script, but sometimes the ore goes when your still waiting and the pickaxe might break
So how would you solve this:
Well what the WaitWhileMining procedure looks like is:
procedure WaitWhileMining;
begin
repeat
NAutoRespond;
FindFastRandoms;
PickChecker;
Check;
if GasFound(fx, fy) then
begin
RunTo('E', False)
wait(7000 + Random(3000))
writeln('We avoided Gas!!! :P')
RunBack;
end;
NAutoRespond;
AntiBan;
until (FindBlackChatMessage('You manage to mine some'))
end;
So we can add a timemark.
procedure WaitWhileMining;
var
Mark : Integer;
begin
MarkTime(Mark);
repeat
NAutoRespond;
FindFastRandoms;
PickChecker;
Check;
if GasFound(fx, fy) then
begin
RunTo('E', False)
wait(7000 + Random(3000))
writeln('We avoided Gas!!! :P')
RunBack;
end;
NAutoRespond;
AntiBan;
until (FindBlackChatMessage('You manage to mine some')) or (TimeFromMark(mark) > 20000))
end;
What this will do is it will time out after 20 seconds from when the pick touches the rock to when 20 secs is up.
See TimeMarks are used everywhere!!!!
VI - End Notes:
The reason why I wrote Chuck Norris in bold was becuase if you don't show him respect then you will die, simple!
If you liked this tutorial then you can Rep++ me :) :) :)
Hope you learned something :).
This tutorial has some quotes from Chuck Norris, those who are not worthy must NOT look!, Or Fear Death!
Table Of Contents:
I - Beginning Notes.
II - Intoduction.
III - Improvisations.
IV - Failsafes.
V - TimeMarks!!
VI - End Notes.
I - Beginning Notes.
Welcome to NaumanAkhlaQ's tutorial on How To Make a Script Run Flawlessly. SO why did I make this tutorial??
Well a script without Failsafes, , TimeMarks and Improvisation[/i] techniques is like Chuck Norris without his roundhouse kicks. <-- Freaky, no?
Every script needs this criteria for it to run flawlessly. N.B, I believe that there is no such thing a flawless becuase nothing is [u]perfect flawless just means good.
Ok so lets begin!!!
II - Introduction.
SO what are Failsafes, TimeMarks and Improvisations.
Well they are what makes a script run Flawlessly.
Ok that this scenario for instance.
Your right outside the general store and you need to get inside, just one problem your in world 1, and it's really crowded.
What could you do?
http://i28.tinypic.com/2vab887.jpg
No Problem you say just use If FindSymbol(x,y,'store') Then... But how will S.C.A.R manage to find the symbol when there are loads of player dots crowding the symbol???
Chuck Norris says "RoundHouse kick all of them in their Faces!!!" Alas it isn't that easy.
III - Improvisations.
Ok so returning to the problem we encountered in chapter II, what could we use?
Ok SO Our Options:
1: Co-ord Clicking.
2: Color Finding;
3: Make it repeat until it finds the symbol.
Ok so I'll put them in order of non-detectability:
2: Color Finding;
3: Make it repeat until it finds the symbol
1: Co-ord Clicking.
So how can we use them in our script, here is an example:
http://i28.tinypic.com/2vab887.jpg
If (not(FindSymbol(x,y,'store'))) Then
Begin
WriteLn('General Store Not found, Trying another tack');
If FindColorSpiral(x,y,47587,Co-ords here) Then
Mouse(x,y,1,1,true)
FFlag(0)
If (Not(FindColorSpiral( x,y,47587,Co-ords here) Then
WriteLn('Couldnt Find Color, now going to co-ord click')
Begin
Mouse(657,655,5,5,true);
FFlag(0)
If (not(FlagPresent)) Then
WriteLn('We have died')
TerminateScript;
end;
end;
^ Thats Just an example, but hounostly it looks very messy so hows about we put it in a seperate Procedure ^
SO here
Procedure TryAgain;
Begin
WriteLn('General Store Not found, Trying another tack');
If FindColorSpiral(x,y,47587,Co-ords here) Then
Mouse(x,y,1,1,true)
FFlag(0)
If (Not(FindColorSpiral( x,y,47587,Co-ords here) Then
WriteLn('Couldnt Find Color, now going to co-ord click')
Begin
Mouse(657,655,5,5,true);
FFlag(0)
If (not(FlagPresent)) Then
WriteLn('We have died')
TerminateScript;
end;
end;
Procedure FindStore;
Begin
If (not(FindSymbol(x,y,'store'))) Then
Begin
TryAgain;
Begin
BuyBuckets; //e.t.c if our script hasn't terminated //
end;
end;
end;
That Looks much better and less messier.
Thats that covered, now what about makeing it repeat until it finds the symbol
Well we could do something like this.
If (Not (FindSymbol(x,y,'store'))) then
Begin
Repeat
If FindSymbol(x,y,'store') then
Result := True;
Mouse(x,y,1,1,true);
Until(Result);
FFlag(0);
end;
^ But what if it doesn't find it wouldn't that be a waste of time, that leads us on to the next chapter on FailSafes.
IV - Failsafes.
Ok so scenario 2 - we can't let it keep trying to find it, we need to make it stop after doing ten tries or something...
And Failsafes do exactly that.
So First we make a variable called Tries as an Integer; .
http://i28.tinypic.com/2vab887.jpg
Procedure FindStore;
var
Tries: Integer; <---- Here!!!
Begin
If (Not (FindSymbol(x,y,'store'))) then
Begin
Repeat
If FindSymbol(x,y,'store') then
Result := True;
Mouse(x,y,1,1,true);
Until(Result);
FFlag(0);
end;
end;
OK SO we made an Integer called tries, now what do we do?
One good thing about an Integer as it will always start at 0 unless specified not to. So we can keep adding on one in a loop until it will get to 10 as they say so our code could look something like this:
Procedure FindStore;
var
Tries: Integer; <---- Here!!!
Begin
If (Not (FindSymbol(x,y,'store'))) then
Begin
Repeat
If FindSymbol(x,y,'store') then
Tries:=Tries+1;
Result := True;
Mouse(x,y,1,1,true);
Until(Result) or (Tries = 10);
FFlag(0);
end;
end;
SO what we are doing there is basically telling it to add one onto zero each time until it gets to ten meaning it will try to find then symbol 10 times. so Tries:=Tries+1; is basically 0:=0+1 and it a second time is 1:=1+1; e.t.c
SO what does
Tries = 10
do? What it does is that it will stop after Tries is equal to 10 meaning it will try and find the symbol store until it finds it or it tires 10 times.
Simple huh....
But Chuck Norris isn't impressed, "So wouldn't it time out just as it reaches ten meaning it might not click???".
Well guess what folks Chucks right again!!!
Procedure FindStore;
var
Tries: Integer; <---- Here!!!
Begin
If (Not (FindSymbol(x,y,'store'))) then
Begin
Repeat
If FindSymbol(x,y,'store') then
Tries:=Tries+1 <--// Will stop here! if it finds it the tenth time//
Result := True;
Mouse(x,y,1,1,true);
Until(Result) or (Tries = 10);
FFlag(0);
end;
end;
So it should look like:
Until(Result) or (Tries > 10);
Becuase when its over ten meaning it will stop after it's clicked the symbol. Thats about all and you can use it if you want to repeat a procedure so you could do (Just for Chuck Norris' pleasure
Repeat
DoRoundHouseKicksOnBadGuys;
i:=i+1;
Until(i> 6{Number Of Bad Guys!})
SO there we go we have made a working Failsafe whilst satisying Chuck Norris :)
V - TimeMarks!!
Ok SO what are TimeMarks?
Well stupid Question lets ask the all knowing Chuck.
Chuck Norris says: "Some code used in a script to make a loop stop after a certain amount of time";
Ok How you use time marks is just declare them a variable first ok lets do Chuck Norris as an Integer.
N.B You must declare the
MarkTime
Before the loop begins.
Example (this would be wrong):
Procedure Chuck;
var Chuck_Norris : Integer;
Begin
Repeat
MarkTime(Chuck_Norris)
Until(TimeFromMark(Chuck_Norris) > (8000))
^That would be wrong as it will start it again from zero so it will never get to 8 seconds, this is what you call an endless loop^
So this would be right:
Procedure Chuck;
var Chuck_Norris : Integer;
Begin
MarkTime(Chuck_Norris)
Repeat
RoundHouseKicks;
Until(TimeFromMark(Chuck_Norris) > (8000))
A good way of reminding you that you should never declare it in a loop is that: Chuck Norris always comes first.
So now you wonder what this does??
Until(TimeFromMark(Chuck_Norris) > (8000))
Well it tells S.C.A.R that it will repeat RoundHouseKicks; for 8 seconds( Not enough time??? Too much time for Chuck Norris.!)
Remember the code that goes Inbetween the brackets must be declared as an Integer!!!.
SO you could use it for something else:
Scenario 3:
Your Mining some coal rocks, with your own script, but sometimes the ore goes when your still waiting and the pickaxe might break
So how would you solve this:
Well what the WaitWhileMining procedure looks like is:
procedure WaitWhileMining;
begin
repeat
NAutoRespond;
FindFastRandoms;
PickChecker;
Check;
if GasFound(fx, fy) then
begin
RunTo('E', False)
wait(7000 + Random(3000))
writeln('We avoided Gas!!! :P')
RunBack;
end;
NAutoRespond;
AntiBan;
until (FindBlackChatMessage('You manage to mine some'))
end;
So we can add a timemark.
procedure WaitWhileMining;
var
Mark : Integer;
begin
MarkTime(Mark);
repeat
NAutoRespond;
FindFastRandoms;
PickChecker;
Check;
if GasFound(fx, fy) then
begin
RunTo('E', False)
wait(7000 + Random(3000))
writeln('We avoided Gas!!! :P')
RunBack;
end;
NAutoRespond;
AntiBan;
until (FindBlackChatMessage('You manage to mine some')) or (TimeFromMark(mark) > 20000))
end;
What this will do is it will time out after 20 seconds from when the pick touches the rock to when 20 secs is up.
See TimeMarks are used everywhere!!!!
VI - End Notes:
The reason why I wrote Chuck Norris in bold was becuase if you don't show him respect then you will die, simple!
If you liked this tutorial then you can Rep++ me :) :) :)
Hope you learned something :).