Log in

View Full Version : Help with my main loop



Archaic
03-15-2012, 06:08 AM
I'm (still) working on an agility script and everything is all but done, but I'm having some troubles shaping the main loop for the script.

I want the script to 1.) log in 2.) If in the agility course, do the agility course obstacles (I have objectDTMs that find where the character is per obstacle enabling the course to be done from any point) 3.) if die, engage death walk, walk back to the course, and then begin doing the agility course all over again until a certain number of laps is done.

I already have all the procedures/functions ready and working, I'm just having troubles shaping the main loop to do all these things in a logical fashion.

My current (more logic than actual code) Main loop:

begin
Smart_Server := 6;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;

SetUpSRL;
ObjDTM_Setup;
ActivateClient;
DeclarePlayers;
LoginPlayer;
MarkTime;
If LoggedIn then
repeat
if (at the agility course) then //one thing I'm wondering about--what can I use for (at the agility course)? I was thinking about just if the character was alive, but i feel that may lead to problems later.
DoAgilityCourse; //each repitition of this only does one obstacle based on position (i.e. all the obstacles are in one procedure--based on position it does one obstacle) so I think I may need to add a loop within a loop but I'm not sure if that would be logical.
if (died) then //I think I can do this part, but which would be better to use: Detecting pixel shift, detecting text, or a combination of both to detect death?
DoDeathWalk; //again divided into several different if then functions within the procedure so same problem arises.
if (breaktime) then
Break;
until(Laps = NumberOfLaps) or (retry = 5) or (TimeFromMark >= TimeToRun);//How could I make this more efficient/use more failsafes?
end.

I'm thinking I'll have to add repeat...until loops within both the DoAgilityCourse and DoDeathWalk loops or within the procedures themselves, but what would the stipulations of the 'until' part of those statements look like?

Overall my question is how can I make this into a logical, efficient main loop?

Thank you in advance for the help:)

LordJashin
03-15-2012, 03:20 PM
You could use Procedures, and functions for a lot of it. Your main loop should be short, concise, and efficient. Put the procedures/functions before the main loop. You could also make an include file.

Mr Stoj
03-15-2012, 03:30 PM
for
(at the agility course)

use 2 symbols to tell it that it is there.

remmeber to inc a failsafe though
#

as for the obsticles

try making a procedure for each object
then

Procedure MainLoop;
var
x, y:Integer;

begin
if not LoggedIn then Exit;
FindNormalRandoms;
Case Stage of

(this is where its easier to multi loop)