SRL Archive - OSR Help

Main Loop Problem


GREEN GIANT

2013-08-23 06:58:38

Hi Guys,

My current script has a lot of If/Then statements, and Repeat/Until statements and i can't seem to get them to work together in my main loop, individually they work fine but when put together it tends to skip stages out even if they are True.

I'm assuming this is because my Begin/Ends are not properly structured but the If/Then and Repeat/Until statements mess it all up. When you click a Begin it turns Red, when i then click the appropriate End, it does not turn Red (i think this means the two aren't paired)

Can anyone rearrange the following to make it work? Or point me to a thorough guide?

In its current layout it compiles but only does the first Runecheck and Buy and skips the others. There are no Begin/Ends in there because i could not get them to pair.

Thanks.

Begin
Declareplayers;
Setupsrl;
Repeat
If (Not LoggedIn()) then
LogInPlayer() else
If (LoggedIn()) then
Wait(2000);
If (CashCheck < 10000) then
HaltScript else
Repeat
FindLundail;
Until Runeshopscreen;
if Runeshopscreen then

if (CheckRuneStockC >= 1) and ((CheckRuneStockC * 50) < CashCheck) then
repeat
BuyRuneC
Until CheckRuneStockC <= 1 else

if (CheckRuneStockN >= 1) and ((CheckRuneStockN * 225) < CashCheck) then
repeat
BuyRuneN
Until CheckRuneStockN <= 1 else

if (StrToInt(DeathRuneCount) >= 209) and ((StrToInt(DeathRuneCount) * 200) < CashCheck) then
repeat
BuyRuneD
Until (StrToInt(DeathRuneCount) <= 200) else
Haltscript;
CloseShop;
ChangeWorldRand;

Until False;

end.

riwu

2013-08-23 07:08:13


Begin
Declareplayers;
Setupsrl;
Repeat
If (Not LoggedIn()) then
LogInPlayer()
else
//If (LoggedIn()) then not needed since it's just opposite of prev boolean
Wait(2000);

If (CashCheck < 10000) then
HaltScript
else
begin //since there's sth else u want to do after the repeat, u need a begin
Repeat
FindLundail;
Until Runeshopscreen; //potential infinite loop

if Runeshopscreen then
begin
if (CheckRuneStockC >= 1) and ((CheckRuneStockC * 50) < CashCheck) then
repeat
BuyRuneC;
Until CheckRuneStockC <= 1
else
if (CheckRuneStockN >= 1) and ((CheckRuneStockN * 225) < CashCheck) then
repeat
BuyRuneN;
Until CheckRuneStockN <= 1
else
if (StrToInt(DeathRuneCount) >= 209) and ((StrToInt(DeathRuneCount) * 200) < CashCheck) then
repeat
BuyRuneD;
Until (StrToInt(DeathRuneCount) <= 200)
else
Haltscript;

CloseShop;
ChangeWorldRand;
end;
end;
Until False;
end.

Practise correct indentation for easier reading of your code.

GREEN GIANT

2013-08-23 07:24:46

From: riwu

Begin
Declareplayers;
Setupsrl;
Repeat
If (Not LoggedIn()) then
LogInPlayer()
else
//If (LoggedIn()) then not needed since it's just opposite of prev boolean
Wait(2000);

If (CashCheck < 10000) then
HaltScript
else
begin //since there's sth else u want to do after the repeat, u need a begin
Repeat
FindLundail;
Until Runeshopscreen; //potential infinite loop

if Runeshopscreen then
begin
if (CheckRuneStockC >= 1) and ((CheckRuneStockC * 50) < CashCheck) then
repeat
BuyRuneC;
Until CheckRuneStockC <= 1
else
if (CheckRuneStockN >= 1) and ((CheckRuneStockN * 225) < CashCheck) then
repeat
BuyRuneN;
Until CheckRuneStockN <= 1
else
if (StrToInt(DeathRuneCount) >= 209) and ((StrToInt(DeathRuneCount) * 200) < CashCheck) then
repeat
BuyRuneD;
Until (StrToInt(DeathRuneCount) <= 200)
else
Haltscript;

CloseShop;
ChangeWorldRand;
end;
end;
Until False;
end.

Practise correct indentation for easier reading of your code.


Hey :)

I dont think i explained what i want it do do, i want it to do all of the CheckRune/BuyRune procedures one after the other, the 'if (CheckRuneStockN >= 1) and ((CheckRuneStockN * 225) < CashCheck) then' is to check that there is enough Runes to buy and that the cost of buying them is less than the cash in inventory.

At present the rearrange you provided only runs the first CheckRune/BuyRune then skips to logging out.

Thankyou for looking at it though :D

GREEN GIANT

2013-08-23 07:37:53

I think i have sorted it, it seems to be working ok.

Turns out the Begin/Ends don't have to be paired in Red to work :/ Who knew?