Results 1 to 5 of 5

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

  1. #1
    Join Date
    Oct 2014
    Location
    Belgium
    Posts
    33
    Mentioned
    0 Post(s)
    Quoted
    9 Post(s)

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

    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


    you can find my script in the Attachments. Inventory Checker full or not full.simba



    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. Inventory Checker full or not full.simba
    Last edited by RSPS Scripter; 02-25-2019 at 04:02 PM. Reason: simba Code is not showing up idk why.

  2. #2
    Join Date
    Jun 2015
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    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.

  3. #3
    Join Date
    Oct 2014
    Location
    Belgium
    Posts
    33
    Mentioned
    0 Post(s)
    Quoted
    9 Post(s)

    Default

    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;

  4. #4
    Join Date
    Jun 2015
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    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:
    Simba Code:
    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;

  5. #5
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by RSPS Scripter View Post
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •