PDA

View Full Version : Failsafes



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

Iron Man
11-07-2008, 06:08 AM
Maybe say which type of failsafes they can use? Like a counter method, MarkTime/TimeFromMark etc.

Also talk about infinite loops or something maybe? That repeat until(conditionismet); looks like an infinite loop to me. :)

Raskolnikov
11-07-2008, 09:21 PM
I talked about infinite loops and yes i will do time from mark hold on