SRL Archive - OSR Help

I need help with how to Check that the inventory is full or not


RSPS Scripter

2019-02-25 05:21:28

Dear Villavu Members,

I am using this version of simba

//You are currently using version: 1300
Compiled with FPC version 3.0.4//

Like i said in the title i need some help how to check if the inventory is full or not.

my goal is to count the inventory for example if its empty it should writeln('Inventory is not full going to supplies')

and if the inventory is full it should writeln('Inventory is full going to bank')

this is so far my script it logs in and opens the Inventory but after that it all goes to shat :confused:


you can find my script in the Attachments. [ATTACH]28622[/ATTACH]



Update to the script.

Its now checking the inventory if its empty it walks to the supplie place and finds the gate and opens it other wise if the inventory is full it will walk to the bank

now i just need to figure it out how to deposite the supplies and picking up the supplies.

this is so far my script you can find it in this Attachments. [ATTACH]28623[/ATTACH]

daileyj93

2019-02-25 08:58:53

If your inventory isn't full, the script is just gonna get stuck in the loop in Check_Inventory. If the only purpose of that function is to check if the inventory is full, you might as well just use Inventory.IsFull by itself. If you want that function to something additional to just checking the inventory, then you should put something in the loop that will make your character fill up his inventory, otherwise it will be stuck in the loop forever. Its also good practice to add a fail-safe, like a timer or a counter to break out of the loop if the inventory never gets full.

RSPS Scripter

2019-02-25 11:09:30

Dear daileyj93,

thank you for helping me.

i was going to use this for a waitloop from this guide https://villavu.com/forum/showthread.php?t=118229

when i try to put it in simba code it all goes to shat idk why so i just copy pasted it.

{*******************************************************************************
Name: waitLoop();
Function: Waits until we have collected our cabbage
*******************************************************************************}
procedure waitLoop();
var
InvCount: Integer;
T: TTimeMarker;
begin
if not SRL.isLoggedIn() then
Exit;

InvCount := Inventory.Count(); //Gets the count in our inventory
T.Start; //Start our timer
repeat
wait(randomRange(75, 250)); //Wait a random amount of time
until((Inventory.Count() > InvCount) or (T.GetTime > 7000)); //Stop repeating once inv count changes or we time out
end;

daileyj93

2019-02-25 11:32:29

The check_Inventory function could be used as a wait loop the way you have it written. But since Walk_to_supplies does not contain any code to fill up the inventory, there is no way for your program to break out of the loop. To be an effective wait loop, you need to do something like the following:

function Check_Inventory(): Boolean;
begin
Result := Gametabs.Open(tabInventory);

while (not Inventory.IsFull) do
begin

if Walk_to_supplies() then
Fill_inventory_wih_supplies(); //add a function to fill the inventory

end;

end;

Dan the man

2019-02-25 20:57:05

From: RSPS Scripter
Dear daileyj93,

thank you for helping me.

i was going to use this for a waitloop from this guide https://villavu.com/forum/showthread.php?t=118229

when i try to put it in simba code it all goes to shat idk why so i just copy pasted it.

{*******************************************************************************
Name: waitLoop();
Function: Waits until we have collected our cabbage
*******************************************************************************}
procedure waitLoop();
var
InvCount: Integer;
T: TTimeMarker;
begin
if not SRL.isLoggedIn() then
Exit;

InvCount := Inventory.Count(); //Gets the count in our inventory
T.Start; //Start our timer
repeat
wait(randomRange(75, 250)); //Wait a random amount of time
until((Inventory.Count() > InvCount) or (T.GetTime > 7000)); //Stop repeating once inv count changes or we time out
end;


You can use the simba tags ["simba"]["/simba"] (remove the "") to format the code correctly.