Jump to content

Opening items in inventory


Syndo

Recommended Posts

On 2/1/2021 at 2:16 AM, skillerkidos1 said:

if(inventory.contains("Feather pack")){

 inventory.getItem("Feather pack").interact("Open");
  //add conditional sleep

}

To improve on this, Item#interact returns a boolean if it was successful or not, so you can do

if(inventory.getItemm("Feath pack").interact("Open")) {
 // Conditional sleep that checks if the number of feather packs in your inventory decreased by 1 
}

 

  • Like 3
Link to comment
Share on other sites

54 minutes ago, Tom said:

To improve on this, Item#interact returns a boolean if it was successful or not, so you can do



if(inventory.getItemm("Feath pack").interact("Open")) {
 // Conditional sleep that checks if the number of feather packs in your inventory decreased by 1 
}

 

I would say it depends on the situation. In case of feather packs, I can imagine you don't want to wait a tick everytime you open one since opening them as quick as possible is what you essentially want. You would probably need different code to prevent trying to interact with a non-existent item.

Edited by Canidae
  • Like 3
Link to comment
Share on other sites

I think this is would be better...

        int chain[] ={0,1,2,3,4,5,6,...,28};
        int chain[] ={0,4,8,12,16,20,24,1,5,9,13,17,...};
        for (int i = 0; i < 28; i++) {
            Item item =getInventory().getItemInSlot(chain[i]);
            if (item!=null &&(item.getName().contains("pack"))){
                getInventory().interact(chain[i],"Open");
              	sleep....
            }

        }

 

  • Like 1
Link to comment
Share on other sites

On 2/1/2021 at 9:05 PM, Nbacon said:

I think this is would be better...


        int chain[] ={0,1,2,3,4,5,6,...,28};
        int chain[] ={0,4,8,12,16,20,24,1,5,9,13,17,...};
        for (int i = 0; i < 28; i++) {
            Item item =getInventory().getItemInSlot(chain[i]);
            if (item!=null &&(item.getName().contains("pack"))){
                getInventory().interact(chain[i],"Open");
              	sleep....
            }

        }

 

This might mess up when trying to pause the script. I would also write it like this:

for (Item item : getInventory().getItems()) {
            if (item != null && item.getName().equals("Feather pack") && item.interact("Open")) {
                //sleep
            }
        }

 

Link to comment
Share on other sites

On 2/4/2021 at 2:57 AM, Nbacon said:

Our loops do the same exact thing and will fuck up in the same way..... but mine can do diffent chaining types...

You forgot to check if the interaction actually was succesful, this way you can trigger the sleep without actually having opened the pack. 

Edited by Canidae
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...