marola 2 Share Posted April 13, 2017 Well, i have a trouble, how i make a code to count how many saltpetre i have digged? i made alot of thinks, but i cant count because i dont know use sleepUntil(new Condition()) pretty good yet i tried to do int count += 1, every time when the method "digSaltpetre" is in action, but it will count only 1 per loop, and in 1 loop i digg like 15-26 saltpetres... how i fix my problem? help me plz guys Link to comment Share on other sites More sharing options...
Diddy 265 Share Posted April 13, 2017 @Override public void onItemChange(Item[] items) { for (Item item : items) { if (item.getName().equals("Saltpetre")) { amount +=1; } } } i gues you could use the onItemChange method. Link to comment Share on other sites More sharing options...
TheMcPker 74 Share Posted April 13, 2017 int temp = getInventory().count("item"); action of digging int digged += (getInventory().count("item") - temp); think that shoud do it Link to comment Share on other sites More sharing options...
marola 2 Author Share Posted April 13, 2017 thank you guys, ill post feedback Id keep the code but change amount += 1; to amount += item.getAmount(); simply because when you lag you might get 2 and it would only add one. Note that you need to implement the InventoryListener for this to work Edit: also make sure that i.getAmount() > 0 because when you bank It will give you a negative number because you have 'lost' the item can you explain me more about inventory listner, im having trouble, bcuz im so confuse where i put this method, my method to dig saltepetre is on a node called saltpetre that do somethings like dig, bank and walk back to dig spot, i need to implement the inventoryListener on Main class or NODE class? Link to comment Share on other sites More sharing options...
marola 2 Author Share Posted April 13, 2017 Main Can you teach me 1 more time plz Well, i tried to make the Override method, but when i created it on MAIN classe, it says "REMOVE OVERRIDE ANOTATTION" i made what you guys said, but still having trouble, im newb on dreambot api, but im working for be good and help dreambot users @Override public void onItemChange(Item[] items) { for (Item item : items) { if (item.getName().equals("Saltpetre") && item.getAmount() > 0) { saltpetreCount += item.getAmount(); } } } Link to comment Share on other sites More sharing options...
None 227 Share Posted April 14, 2017 Can you teach me 1 more time plz Well, i tried to make the Override method, but when i created it on MAIN classe, it says "REMOVE OVERRIDE ANOTATTION" i made what you guys said, but still having trouble, im newb on dreambot api, but im working for be good and help dreambot users @Override public void onItemChange(Item[] items) { for (Item item : items) { if (item.getName().equals("Saltpetre") && item.getAmount() > 0) { saltpetreCount += item.getAmount(); } } } you did not implement InventoryListener, it goes at the top of your script right after extends AbstractScript public class LavaDragons extends AbstractScript implements InventoryListener { Link to comment Share on other sites More sharing options...
marola 2 Author Share Posted April 14, 2017 you did not implement InventoryListener, it goes at the top of your script right after extends AbstractScript public class LavaDragons extends AbstractScript implements InventoryListener { thank you they solved my problem on discord, whatever, thank you again and here is my feedback i implemented InventoryListener like you guys said and made it @Override public void onItemChange(Item[] items) { for (Item item : items) { if (item != null && item.getName().contains("Saltpetre") && item.getAmount() > 0) { saltpetreCount += item.getAmount(); } } } now its working, thank you alot guys Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.