Raskolnikov
11-07-2008, 05:03 AM
I'm here to talk about failsafes, which make your script more efficient.
Here is the golden rule for failsafes. When using an until(false), you must always, always, always, have a failsafe. When doing multiplayer it is usually:
repeat
if not LoggedIn then Break; //here is the golden failsafe here, if we aren't logged in, we break out of endless loop.
//do whatever
until(false);
Now, where else do you need failsafes?
procedure FailsafeTest;
begin
repeat
if not LoggedIn then Exit;
until(ConditionIsMet);
end;
What if we log out of inactivity before the condition is met? If we didn't have our failsafe, we could have a stalled script on our hands.
Here's another example by using TimeFromMark:
MarkTime(Timer); //We must declare timer as an integer
repeat
DoWhatever;
until(TimeFromMark(Timer) >= 10000); //We are saying we will do "DoWhatever" until the timer is greater than or equal to 10 seconds.
Please post comments!
Cut em2 it
Here is the golden rule for failsafes. When using an until(false), you must always, always, always, have a failsafe. When doing multiplayer it is usually:
repeat
if not LoggedIn then Break; //here is the golden failsafe here, if we aren't logged in, we break out of endless loop.
//do whatever
until(false);
Now, where else do you need failsafes?
procedure FailsafeTest;
begin
repeat
if not LoggedIn then Exit;
until(ConditionIsMet);
end;
What if we log out of inactivity before the condition is met? If we didn't have our failsafe, we could have a stalled script on our hands.
Here's another example by using TimeFromMark:
MarkTime(Timer); //We must declare timer as an integer
repeat
DoWhatever;
until(TimeFromMark(Timer) >= 10000); //We are saying we will do "DoWhatever" until the timer is greater than or equal to 10 seconds.
Please post comments!
Cut em2 it