PDA

View Full Version : The importance of marks in failsafes



Ultra
12-07-2009, 09:48 PM
The importance of marks in failsafes
I haven't seen a tutorial on marks yet so i made this. Marks are very helpful in scripting, but tutorial writers tend to forget to include them in their tutorials and it just makes a whole lot harder for people to start scripting.

Before starting to read/understand this tutorial you must be familiar with all scar basics. If you are not, please visit the beginner tutorial section (http://villavu.com/forum/forumdisplay.php?f=95).

Index
1. What is a mark?
2. Usage and understanding of marks.

1. What is a mark.
A mark could be defined in scar as a beginning or ending of a time/unit measurement. They are mostly used in scripts as types fail safes in loops.

2. Usage and understanding of marks.
Simple integer marks can appear or be used as the following:
program New_Script;
{.Include SRL/SRL.Scar}

var
OurMark : Integer;//Define OurMark as an integer.

begin
SetUpSRL;

OurMark := 0;//Sets OurMark to 0.
repeat//Starts a loop and adds one to OurMark each 10 miliseconds
begin
OurMark := OurMark + 1;
Wait(10);
WriteLn(IntToStr(OurMark));
end;
until(OurMark=5);//Ends the loop once OurMark reaches 5.

for OurMark:=0 to 5 do//Sets OurMark to 0 and adds one each 10 miliseconds.
begin
Wait(10);
WriteLn(IntToStr(OurMark));
end;//Once OurMark reaches 5 it will quit.

end.
This simple integer mark can be used in many different loops such as the For and Repeat until loops, but they will all do the same thing. These marks interrupt the script each time they change.

program New_Script;
{.Include SRL/SRL.Scar}

var
OurTimeMark : Integer;//Define OurMark as an integer.

begin
SetUpSRL;

MarkTime(OurTimeMark);//Starts OurTimeMark.
repeat//Starts a loop.
begin
Wait(10);//Waits 10 miliseconds, in here to decrease lag.
WriteLn(IntToStr(TimeFromMark(OurTimeMark)));
end;
until(TimeFromMark(OurTimeMark)>5000);//While the time that has passed since we marked our time
//is more than 5000 miliseconds it will wait.

MarkTime(OurTimeMark);//Starts OurTimeMark.
while TimeFromMark(OurTimeMark)<5000 do//While the time that has passed since we marked our time
begin //is less that 5000 miliseconds it will do the following:

Wait(10);//Waits 10 miliseconds, in here to decrease lag.
WriteLn(IntToStr(TimeFromMark(OurTimeMark)));
end;

end.
These time marks (counters) do not interrupt your loops, think of these marks as if they create a small invisible script that measures time from point a to point b, and when the time reaches point b the little script tells your big script that it has reached it. They do not interrupt your script unless you make them to do so.
They are useful when you want do do something for a certain period of time and not for a certain period of actions.

Here is an example of how i used the time mark in a fishing script:
procedure Fishing;
var
Start : Integer;
Finish : Integer;
begin
DropTheInv := False;
if Players[CurrentPlayer].Active=True then
begin
Disguise('Fishing...');
Finish := RandomRange(FishForMin*1000, FishForMax*1000);//Set by the user in const.
MarkTime(Start);
while(LoggedIn)and(TimeFromMark(Start)<Finish)do
begin
Wait(RandomRange(900, 2000));
FindNormalRandoms;
if TheInvIsFull or InvFull then begin DropTheInv:=True; Disguise('Inventory full...'); Exit; end;
if RandomRange(1, 10)=9 then MoveCompassRandom;
if RandomRange(1, 8)=7 then MousingWhileFishing;
end;
Disguise('Switching spots...');
end;
end;

Thanks for reading, help me out by telling me what else i could add about marks.

Method
12-07-2009, 10:05 PM
It might be more clear if you used the phrase "time mark(er)" instead of just mark. I would also call the integer "marks" counters, but I don't think it matters all that much.

It looks fine otherwise, nice job. :)

Ultra
12-07-2009, 10:08 PM
It might be more clear if you used the phrase "time mark(er)" instead of just mark. I would also call the integer "marks" counters, but I don't think it matters all that much.

It looks fine otherwise, nice job. :)
Ok, i added (counters) in brackets into tut. Thanks.

Blumblebee
12-07-2009, 10:42 PM
I'm thinking those arent exactly the correct standards :p but it looks good. I think this should be in beginners section though, not intermediate.

Ultra
12-07-2009, 10:44 PM
I'm thinking those arent exactly the correct standards :p but it looks good. I think this should be in beginners section though, not intermediate.
Yeah sry bout standards XD.

I thought about where this would be and i think its better for this to be in intermediate because complicated uses of counters/marks/whatever are not really for beginners.

Heavenguard
12-07-2009, 11:04 PM
Yeah sry bout standards XD.

I thought about where this would be and i think its better for this to be in intermediate because complicated uses of counters/marks/whatever are not really for beginners.

Agreed, Beginner Tutorials seem to cram in a lot of things at once, I dont think marks should be included there, as a matter of fact I think it should be in the advanced :O. Or as a Miscellaneous thing, its extremely useful, but of course, not usually something we would want to learn first.

Great job Ultra :D really really good job :D <3 u.

Ultra
12-08-2009, 02:58 AM
Agreed, Beginner Tutorials seem to cram in a lot of things at once, I dont think marks should be included there, as a matter of fact I think it should be in the advanced :O. Or as a Miscellaneous thing, its extremely useful, but of course, not usually something we would want to learn first.

Great job Ultra :D really really good job :D <3 u.
Nah, advanced is far too complicated from this lol...

Cigue
12-30-2009, 02:57 AM
Nah, advanced is far too complicated from this lol...

Then why can't I get my hands on the use of marks... What are they for?

NCDS
12-30-2009, 03:07 AM
Then why can't I get my hands on the use of marks... What are they for?

Say you want to do something 3 times. Or try something 5 times and if it still hasn't worked quit.

That's what they are for.

As you get more into scripting you will see use for them.