I was wondering if there was a way to make the script jump to the very top instead of recursing it, something similar to exit except for the fact that it would re-start instead of end
I was wondering if there was a way to make the script jump to the very top instead of recursing it, something similar to exit except for the fact that it would re-start instead of end
put it in a loop and use continue;
or don't use a loop and use labels. A lot of people frown on them, but I use them and never have problems. I thin a lot of people just find them hard to follow.
meh I personally frown upon labels, so best bet is to simply use recursion and exit right after I recurse it?
I frown upon labels too
I tend to use a repeat...until(true) loop instead. You can go to the top of the loop as if it was a label using Continue instead of goto, and you can exit the 'label' (loop) using Break
SCAR Code:procedure Gamble;
begin
if (Random(2) = 0) then
begin
WriteLn('Win!');
Gamble;
Exit;
end;
WriteLn('Lose!');
end;
begin
Gamble;
end.
function procedures that call themselves.
are you able to do that?
I still don't know why people don't like labels...
Current Script Project
Pot of flour gatherer - 95% done
Can't get Simba to work? Click here for a tutorial
Ummm... here is my example of why I used it, thought it would be the best way of going around it:
Simba Code:// procedure to take care of smelting all the ores
procedure SmeltAll();
var ores:integer;
begin
ClickSmelter;
ClickSmeltAll;
Sleep(3000+random(random(500)));
// main procedure loop, will run until out of iron ore
repeat
// counts iron ores, if 0 then exits the procedure
ores := R_CountItemName('Iron ore');
if ores = 0 then
exit;
// if not done smelting will check for randoms and wait a bit
//FindNormalRandoms;
Sleep(2500 + random(random(500)));
// checks to see if the ore count is going down, if not
// will recurse the function, after the recursed function is done
// will come back to this one and exit immediatly
if ores = R_CountItemName('Iron ore') then
begin
SmeltAll();
Exit;
end;
until false
end;
Yes it's quite handy in making complex loops!
SCAR Code:{*******************************************************************************
function Abyss_FindEntrance(var Escaped: Boolean): Boolean;
By: IceFire908
Description: Finds and enters any available abyssal entrances.
*******************************************************************************}
function Abyss_FindEntrance(var Escaped: Boolean): Boolean;
var
EntranceInfo: TVariantArray;
TPAA: T2DPointArray;
TPA: TPointArray;
II, T: LongInt;
AFE: TPoint;
CH: string;
I: Byte;
begin
if (Players[CurrentPlayer].Loc <> 'Abyss outer-circle') then
Exit;
for I := 0 to 2 do
begin
case I of
0: case Abyss_Tool of
'Pickaxe': EntranceInfo := ['Rocks', 0.04, 0.39, 5400967, 13, 70, 70, 200, 'anage', 'ail', 'ine'];
'Hatchet': EntranceInfo := ['Tendrils', 0.05, 0.21, 6646408, 10, 10, 10, 50, 'anage', 'ail', 'hop'];
else
EntranceInfo := [];
end;
1: EntranceInfo := ['Green eyes', 0.05, 0.19, 2124121, 7, 20, 20, 100, 'neak', 'istract', 'istrac'];
2: EntranceInfo := ['Yellow eyes', 0.03, 0.21, 1279367, 7, 30, 30, 100, 'neak', 'istract', 'istrac'];
end;
if (I > 0) then
if (not (UseAbyssEyes)) then
if (PlayerRune <> 'Law') then
if (Abyss_Tool <> '') then
Continue;
if (Length(EntranceInfo) < 1) then
Continue;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(EntranceInfo[1], EntranceInfo[2]);
FindColorsTolerance(TPA, EntranceInfo[3], MSX1, MSY1, MSX2, MSY2, EntranceInfo[4]);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(1);
if (Length(TPA) < EntranceInfo[7]) then
Continue;
TPAA := TPAToATPAEx(TPA, EntranceInfo[5], EntranceInfo[6]);
SortATPASize(TPAA, True);
ATPADebug(TPAA, 'Bounds');
for II := 0 to High(TPAA) do
begin
if (Length(TPAA[II]) < 25) then
Continue;
AFE := MiddleTPA(TPAA[II]);
if (Distance(AFE.X, AFE.Y, MSCX, MSCY) < 10) then
Continue;
MMouse(AFE.X, AFE.Y, 0, 0);
Wait(200 + Random(50));
if (CountColorTolerance(14342657, 7, 7, 100, 25, 70) > 35) then
begin
GetMousePos(AFE.X, AFE.Y);
Mouse(AFE.X, AFE.Y, 0, 0, False);
Wait(RandomRange(500, 800));
if (not (ChooseOption(EntranceInfo[10]))) then
Continue;
WriteLn('Found ' + EntranceInfo[0] + '!');
Wait(200 + Random(50));
Flag;
Wait(200 + Random(50));
T := GetSystemTime;
repeat
Wait(100 + Random(200));
CH := GetBlackChatMessage;
if ((Pos(EntranceInfo[8], CH) > 0) or (InInnerRing)) then
begin
Result := True;
WriteLn('Made it through!');
Wait(RandomRange(1200, 1400));
Players[CurrentPlayer].Loc := 'Abyss inner-circle';
Exit;
end;
if (Pos(EntranceInfo[9], CH) > 0) then
begin
WriteLn(CH + ' Retrying!');
Result := Abyss_FindEntrance(Escaped);
Exit;
end;
if ((GetSystemTime - T) > 15000) then
begin
WriteLn('Time out! Going to next entrance...');
Exit;
end;
if (LowHP) then
begin
Escaped := True;
Exit;
end;
until (False);
end;
end;
end;
WriteLn('No entrance found yet.');
end;
There are currently 1 users browsing this thread. (0 members and 1 guests)