SRL Archive - OSR Help

Problem with script - skips a procedure?


Herbs N Tea

2013-05-22 09:36:52

I've only discovered simba about a week ago, started botting and wanted to start making my own scripts. So I read some guides and started making my own script two days ago. It's really really basic, has no antibans or antirandoms nothing like that.

My script seems to work, but when it starts his second run through the main loop he just skips the first procedure wich is banking;

( the script should withdraw supplies from the pest control bank, then make prayer potions and bank them - repeat )

My main loop:

var
t : Integer;

begin
Setup;
repeat
Banking;
ClickPot;
ClickHerb;
Mixing;
MarkTime(t);
while ExistsItem(28) do
begin
wait(100);
if TimeFromMark(t) > 20000 then
begin
writeln('Took to much time to complete inv. Breaking out of loop');
Break;
end;
end;
writeln('We made potions!');
until not (LoggedIn);
Terminatescript;
end.

My banking procedure:

procedure Banking;
var
I : Integer;

begin
MakeObj('bank', 5599869, 2, 0.22, 0.53, [ 'ank', 'ank', 'ooth'], ['ank']);

if (ExistsItem(27)) then
begin
Writeln('Starting to make potions');
end else

begin
SmartColors('bank');
wait(400 + random(100));
if (BankScreen = True) then
begin
DepositAll;
wait(150 + random(63));
Withdraw(0, 0, 14);
wait(150 + random(67));
Withdraw(1, 0, 0);
wait(100 + random(95));
CloseBank;
end else
I := 1;
repeat
SmartColors('bank');
I := (I + 1);
wait(1000 + random(224));
until (I = 5);
end;

end;

So what happens is, the script succesfully logs in, opens the bank and withdraws supplies from 1st and 2nd bank slot, it closes the bank and makes the pots. Than when it should bank again, it doesn't and skips to procedure ClickHerb; OR it opens the bank and than skips to procedure Clickpot/Clickherb.

I'm not sure what to do, any help or tips would be greatly appreciated

Sjoe

2013-05-23 03:10:28

After you've done a load, are there 27 items in your inventory then?

in your banking procedure u have this line:

if (ExistsItem(27)) then
begin
Writeln('Starting to make potions');
This won't bank if an item exists on the 27th slot.
It will skip the whole banking procedure and move on with the mainloop.

Herbs N Tea

2013-05-23 05:08:24

From: Sjoe
After you've done a load, are there 27 items in your inventory then?

in your banking procedure u have this line:

if (ExistsItem(27)) then
begin
Writeln('Starting to make potions');
This won't bank if an item exists on the 27th slot.
It will skip the whole banking procedure and move on with the mainloop.


No, after doing a load theres 14 items in my inventory. I could've made it check slot 15 but I gues with this line it will still look for supplies if you've allready made for example halve the inventory.

Thanks alot for taking a look tho :)


/edit, I just noticed checking item 27 is really stupid, since this slot will only be empty when the inv is almost done >.<

Sjoe

2013-05-23 06:07:25

When I'm in doubt I always make debug lines, to see where the script is.
Like u did for if ExistsItem(27) then writeln(' starting to make potions') , do this variously for other places.
Debugging is a powerful scripting tool to use!

also:

while ExistsItem(28) do // shouldnt this be ExistItem(15)?
begin
wait(100);
if TimeFromMark(t) > 20000 then
begin
writeln('Took to much time to complete inv. Breaking out of loop');
Break;
end;
end;

The Mayor

2013-05-23 06:23:20

From: Herbs N Tea
No, after doing a load theres 14 items in my inventory. I could've made it check slot 15 but I gues with this line it will still look for supplies if you've allready made for example halve the inventory.

Thanks alot for taking a look tho :)


/edit, I just noticed checking item 27 is really stupid, since this slot will only be empty when the inv is almost done >.<


Ok without seeing the rest of your script I can't be sure, but I think I may know your problem.


procedure Banking;
var
I : Integer;

begin // Ok let's say MakeObj failed to find the bank
MakeObj('bank', 5599869, 2, 0.22, 0.53, [ 'ank', 'ank', 'ooth'], ['ank']);

if (ExistsItem(27)) then //after you make pots inv slot 27 will be empty
begin
Writeln('Starting to make potions'); //therefore it will skip this
end else

begin // and begin this instead
SmartColors('bank');
wait(400 + random(100));
if (BankScreen = True) then //the bank screen wont be open as MakObj failed
begin //so it skips this
DepositAll;
wait(150 + random(63));
Withdraw(0, 0, 14);
wait(150 + random(67));
Withdraw(1, 0, 0);
wait(100 + random(95));
CloseBank;
end else
I := 1; // and starts down here
repeat
SmartColors('bank');
I := (I + 1);
wait(1000 + random(224));
until (I = 5);// not sure what this loop is. Just repeats a 1 sec wait?
end;
end; // and the Banking procedure has ended an all we did was wait 4 seconds :/


So, maybe you could do something like this:



procedure Banking;
var
I, bankTime: Integer;

begin
if (InvCount > 0) then // if stuff in inv then look for the bank!
begin
markTime(bankTime);
repeat
SmartColors('bank'); // I assume this is a status painted on smart
MakeObj('bank', 5599869, 2, 0.22, 0.53, [ 'ank', 'ank', 'ooth'], ['ank']);
wait(400 + random(100));
until bankScreen or (timeFromMark(bankTime) > 20000);
//now it will repeat MakeObj until it finds the bank screen or times out.

if BankScreen then
begin
writeln('found bank')
DepositAll;
wait(150 + random(63));
Withdraw(0, 0, 14);
wait(150 + random(67));
Withdraw(1, 0, 0);
wait(100 + random(95));
CloseBank;
end else
writeLn('failed to find bank'); { If this displays in the debug box }
end; { Then you know MakeObj failed to find the bank }
end; { after 20 seconds }

Herbs N Tea

2013-05-23 06:44:27

From: Sjoe
When I'm in doubt I always make debug lines, to see where the script is.
Like u did for if ExistsItem(27) then writeln(' starting to make potions') , do this variously for other places.
Debugging is a powerful scripting tool to use!

also:

while ExistsItem(28) do // shouldnt this be ExistItem(15)?
begin
wait(100);
if TimeFromMark(t) > 20000 then
begin
writeln('Took to much time to complete inv. Breaking out of loop');
Break;
end;
end;


Thanks for the tip, I didn't even think about adding more lines for debugging :P (I only started this two days ago)

And it shouldn't be 15, because I want it to keep waiting untill theres no item in slot 28


From: The Mayor
Ok without seeing the rest of your script I can't be sure, but I think I may know your problem.


procedure Banking;
var
I : Integer;

begin // Ok let's say MakeObj failed to find the bank
MakeObj('bank', 5599869, 2, 0.22, 0.53, [ 'ank', 'ank', 'ooth'], ['ank']);

if (ExistsItem(27)) then //after you make pots inv slot 27 will be empty
begin
Writeln('Starting to make potions'); //therefore it will skip this
end else

begin // and begin this instead
SmartColors('bank');
wait(400 + random(100));
if (BankScreen = True) then //the bank screen wont be open as MakObj failed
begin //so it skips this
DepositAll;
wait(150 + random(63));
Withdraw(0, 0, 14);
wait(150 + random(67));
Withdraw(1, 0, 0);
wait(100 + random(95));
CloseBank;
end else
I := 1; // and starts down here
repeat
SmartColors('bank');
I := (I + 1);
wait(1000 + random(224));
until (I = 5);// not sure what this loop is. Just repeats a 1 sec wait?
end;
end; // and the Banking procedure has ended an all we did was wait 4 seconds :/


So, maybe you could do something like this:



procedure Banking;
var
I, bankTime: Integer;

begin
if (InvCount > 0) then // if stuff in inv then look for the bank!
begin
markTime(bankTime);
repeat
SmartColors('bank'); // I assume this is a status painted on smart
MakeObj('bank', 5599869, 2, 0.22, 0.53, [ 'ank', 'ank', 'ooth'], ['ank']);
wait(400 + random(100));
until bankScreen or (timeFromMark(bankTime) > 20000);
//now it will repeat MakeObj until it finds the bank screen or times out.

if BankScreen then
begin
writeln('found bank')
DepositAll;
wait(150 + random(63));
Withdraw(0, 0, 14);
wait(150 + random(67));
Withdraw(1, 0, 0);
wait(100 + random(95));
CloseBank;
end else
writeLn('failed to find bank'); { If this displays in the debug box }
end; { Then you know MakeObj failed to find the bank }
end; { after 20 seconds }


Wow, I see what I did wrong now, thanks alot!

Your post was really helpfull, sometimes I just drown in all these lines ~.~

Sjoe

2013-05-23 07:09:38

From: Herbs N Tea
Thanks for the tip, I didn't even think about adding more lines for debugging :P (I only started this two days ago)
And it shouldn't be 15, because I want it to keep waiting untill theres no item in slot 28


My bad, got confused.

Herbs N Tea

2013-05-23 07:52:54

Also,

From: The Mayor

repeat
SmartColors('bank');
I := (I + 1);
wait(1000 + random(224));
until (I = 5);// not sure what this loop is. Just repeats a 1 sec wait?


that loop starts with function SmartColors, wich in this case, finds and opens the bank.

So it tries to open the bank, than waits a second, wich ofcourse isn't very usefull if it ends the procedure after >.<


With the code you posted it should work, I'm still at school trying this as soon as I get home ^^