January 31, 20215 yr I was making a script that at some point needed to open feather packs, but i cant find a way to open them. if(getInventory().contains(11881)) { if inventory contains feather pack, open. but how? } I checked the api but couldnt find an answer.
January 31, 20215 yr if(inventory.contains("Feather pack")){ inventory.getItem("Feather pack").interact("Open"); //add conditional sleep }
January 31, 20215 yr Author 3 minutes ago, skillerkidos1 said: if(inventory.contains("Feather pack")){ inventory.getItem("Feather pack").interact("Open"); //add conditional sleep } Thanks!
February 1, 20215 yr 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 }
February 1, 20215 yr 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 February 1, 20215 yr by Canidae
February 1, 20215 yr 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.... } }
February 3, 20215 yr 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 } }
February 4, 20215 yr 17 hours ago, Canidae said: This might mess up when trying to pause the script. I would also write it like this: Our loops do the same exact thing and will fuck up in the same way..... but mine can do diffent chaining types...
February 7, 20215 yr 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 February 7, 20215 yr by Canidae
February 7, 20215 yr 26 minutes ago, Canidae said: You forgot to check if the interaction actually was succesful, this way you can trigger the sleep without actually having opened the pack. Why would you care if the interaction is succesful? you just click and move on and if it fails come back with a second(slower) pass
February 7, 20215 yr 48 minutes ago, Nbacon said: Why would you care if the interaction is succesful? you just click and move on and if it fails come back with a second(slower) pass I agree, I think it's better to not check if interaction is successful. This way, you won't always open items in the perfect order every time.
Create an account or sign in to comment