SRL Archive - Jr. Member General Help and Discussion

Starting from any point in your script?


cosmasjdz

2014-10-09 15:47:40

hi guys, i tried to update my script so it could start/fix fail from any point of it i made something like this:

procedure fix
check if need fix;
if tabbackpack empty and at shitplace then killgshit, runningtobankshit,bankingshit, exit;
and so on till i come back to the afterbank shit...
end

procedure mainloop
fix
afterbank
goingtoshit
killingshit
runningtobankshit
bankingshit
end

repeat
mainloop
until false

Was thinking to writing a quick reguiding procedure to the certain spot fo example always to the afterbank so when its there despite where it started it can run mainloop from the right place.
The problem is for example killingshit has fix as a failsafe and if i am calling killingshit in fix it goes to infinitive loop….. iv tried to add variables to fix procedure and global ones to to stop this loop but they doesnt help cause everytime i run fix i get new instance it is never ending tree…Its like procedure calling itself within itself without the end…. what can i do else to make something like universal failsafe/ functions which could guide my charachter to start from the right spot?

Hoodz

2014-10-09 16:19:25

what i do is just to make a loop that checks through things

example:

repeat
if (not LoggedIn) then
begin
LogInPlayer;
SetAngle(0);
SetRun(True);
SetFightMode(TrainingMode);
AL_GameTab(Tab_Inv);
GenerateHp;
end;
if (LoggedIn) then
begin
if (IsIncombat) then
begin
Eating_Food;
if (USEPOTS) then
begin
if (ATTACKPOT) then
begin
if (GetSkillInfo('attack', true) > (GetSkillInfo('attack', false) + 2)) then
AttackPotProc;
end;
if (STRENGTHPOT) then
begin
if (GetSkillInfo('strength', true) > (GetSkillInfo('strength', false) + 2)) then
StrengthPotProc;
end;
end;
end
else
AttackMonster;
end;
until (false);

bg5

2014-10-10 21:59:24

This starts loop from any point you want.

program new;

function GetLocation : integer;
begin
Result := 3; // in example it's fixed ofc
end;

function IsFixNeeded: boolean;
begin
result := TRUE;// in example it's fixed ofc
end;

procedure mainloop();
var
Flag : integer;
FixIt :boolean;
begin
while (true) do
begin
Flag := 0; // Reset flag at beginning

FixIt := IsFixNeeded();

if FixIt then
begin
case GetLocation of
-1: writeln('unkown location');
1: Flag := 1;
2: Flag := 2;
3: Flag := 3;
4: Flag := 4;
end;
end;

if (FixIt)and(Flag <= 0 ) then
writeln('afterbank');
if (FixIt)and(Flag <= 1 ) then
writeln('goingtoshit');
if (FixIt)and(Flag <= 2 ) then
writeln('killingshit');
if (FixIt)and(Flag <= 3 ) then
writeln('runningtobankshit');
if (FixIt)and(Flag <= 4 ) then
writeln('bankingshit');

wait(3000);


end;
end;

begin
MainLoop();
end.

btw. I've made first variant using goto/label ,but it was so buggy I retreated.