December 14, 201510 yr How to track how much i picked up of one specific item? I want to kill chickens and track how many feathers i gain
December 14, 201510 yr How to track how much i picked up of one specific item? I want to kill chickens and track how many feathers i gain private long feathersCollected; private long prevInvCount; @Override public void onStart(){ // initialise previous inventory count to current inventory count prevInvCount = getInventory().getAmount("Feather"); } @Override public int onLoop(){ long invCount = getInventory().getAmount("Feather"); // get number of feathers in inventory // If the amount of feathers has increased, add the change to total feathers collected if(invCount > prevInvCount) feathersCollected += (invCount - prevInvCount); // Update previous inventory count to current count prevInvCount = invCount; ... } (This accounts for if you are banking, or if you are disposing of the items e.g. burying bones) If you aren't banking: private long startFeatherCount; @Override public void onStart(){ startFeatherCount = getInventory().getAmount("Feather"); } private long getFeathersCollected(){ return getInventory().getAmount("Feather") - startFeatherCount; } If you want to make it so that the updating of the count is not paused by the bot's actions, you can move the code in onLoop to the onPaint method. However you should ensure that you limit the amount of times it is called per second. Edited December 14, 201510 yr by Explv
December 14, 201510 yr Author private long feathersCollected;private long prevInvCount;@Overridepublic void onStart(){ prevInvCount = getInventory().getAmount("Feather");}@Overridepublic int onLoop(){ long invCount = getInventory().getAmount("Feather"); if(invCount > prevInvCount) featherCount += (invCount - prevInvCount); else prevInvCount = invCount; ...}But what about bones, if i pick them up and bury them, how would i do it then?
December 14, 201510 yr But what about bones, if i pick them up and bury them, how would i do it then? bonesBuried = (currentXp - startXp) / boneXP or if(inventory.interact("Bury", "Bones")) bonesBuried++; or onMessage(Message m) { if(m.getMessage().contains("bury")) bonesBuried++; }} (find the correct message, and only check game messages) Edited December 14, 201510 yr by FrostBug
December 14, 201510 yr Author bonesBuried = (currentXp - startXp) / boneXPThats not what i meant, i know how to get how many i burried, but i want ton get how many i picked up too
December 14, 201510 yr Thats not what i meant, i know how to get how many i burried, but i want ton get how many i picked up too Same way as the feather issue, then.
December 14, 201510 yr Thats not what i meant, i know how to get how many i burried, but i want ton get how many i picked up too See the first part of the solution i posted, and substitute "Feather" for "Bones" .
December 14, 201510 yr I would go for the solution frostbug gave you: onMessage(Message m) { if(m.getMessage().contains("bury")) bonesBuried++; }} (find the correct message, and only check game messages) Since you can use the same method to track other stuff.
Create an account or sign in to comment