Jump to content

Interact with all items in the inventory given a name


Nebulae

Recommended Posts

I'm making a combat script right now which kill mobs, and if the user requests it will pick up bones and bury them. I wait for the inventory to fill up and then do a check for all of the drop / banking needs of the script.

 

I want to make a method which will work for future uses as well and you can just give it a specific item and interact option and it will iterate over each item in the inventory and execute the interact command.

 

Currently the script has a problem where it will detect all of the bones, it will do the interact command but it gets way ahead of its self. Say if the inventory has 6 bones, it will spam click really bad on the first bone, and sometimes click the second bone and just stop.

 

I didn't want to use a while loop checking to make sure the inventory doesn't have anymore of that item in it since I wanted to make this method as I said more robust and not just for burying bones. So I can use it for multiple commands whenever they come up besides just burying.

 

I was wondering if there's a more elegant way of making sure the command has executed through the client vs just doing random sleeping amounts and hoping the script doesn't miss an item.

Edited by Nebulae
Link to comment
Share on other sites

Use conditional sleeps when u bury each bone, eg store the valur of bones in inventory then click and wait until the amount of bones in invent is less than the stored value :)

Edit; eg:

if inventory contains bones

oldBones = inventory.getitem("bones").getAmount();

8nventory,".getitem("bones").interact("bury");

new ConditionalSleep(2000) {

@ Override

public boolean condition() throws InterruptedException {

return oldBones > inventory.getitem("bones").getamount;

}

}.sleep();

Sry for text wrote on phone

Edited by IHB
  • Like 1
Link to comment
Share on other sites

Use conditional sleeps when u bury each bone, eg store the valur of bones in inventory then click and wait until the amount of bones in invent is less than the stored value smile.png

Edit; eg:

if inventory contains bones

oldBones = inventory.getitem("bones").getAmount();

8nventory,".getitem("bones").interact("bury");

new ConditionalSleep(2000) {

@ Override

public boolean condition() throws InterruptedException {

return oldBones > inventory.getitem("bones").getamount;

}

}.sleep();

Sry for text wrote on phone

nailed it

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...