Protoprize Posted December 14, 2019 Posted December 14, 2019 Sooo.... I've spent a while away from making scripts but since I finally have time to work on some stuff, I've decided to make a simple motherload miner The code is mostly done and I'm planning to release it at some point, but I only have one problem.... RS2Object oreDeposit = api.getObjects().closest("Ore vein"); String objectName = oreDeposit.getName(); int objectModelID = oreDeposit.getId(); if(api.getMap().canReach(oreDeposit)) { oreDeposit.interact("Mine"); api.log("Waiting to be done mining"); new ConditionalSleep(6000, 8000) { @Override public boolean condition() { return !api.getObjects().closest(objectModelID).getName().equals("Ore vein"); } }.sleep(); I've made this simple conditional sleep, which checks the model ID of the previously saved object, and compares it to what it expected to be there while the ore is mineable, All is good while it is still called 'ore vein', but after it depletes, it starts freaking out (I have to force close it) with a NullPointerException I've checked the modeID before and after it has depleted, and it does not change, therefore I am here to see what you guys suggest! Or I accept being absolutely retarded (it do be like that sometimes)
HeyImJamie Posted December 14, 2019 Posted December 14, 2019 You need to null check. The NPE thrown will direct you to where.
Protoprize Posted December 14, 2019 Author Posted December 14, 2019 (edited) 2 hours ago, HeyImJamie said: You need to null check. The NPE thrown will direct you to where. I've added check for it and now the error is gone???????? No output or anything even when using catch (NullPointerException e) { api.log(e.getMessage()); } Decided to split two functions and now it works I still have no idea how I fixed it Edited December 15, 2019 by Protoprize
FuryShark Posted December 15, 2019 Posted December 15, 2019 RS2Object oreDeposit = getObjects().closest("Ore vein"); String objectName = oreDeposit.getName(); int objectModelID = oreDeposit.getId(); if(oreDeposit != null && getMap().canReach(oreDeposit)) { oreDeposit.interact("Mine"); log("Waiting to be done mining"); new ConditionalSleep(6000, 8000) { @Override public boolean condition() { return getObjects().closest(objectModelID) != null && getObjects().closest(objectModelID).getName().equals("Ore vein"); } }.sleep(); }
Cod3xDev Posted May 28, 2022 Posted May 28, 2022 On 12/15/2019 at 10:33 AM, FuryShark said: RS2Object oreDeposit = getObjects().closest("Ore vein"); String objectName = oreDeposit.getName(); int objectModelID = oreDeposit.getId(); if(oreDeposit != null && getMap().canReach(oreDeposit)) { oreDeposit.interact("Mine"); log("Waiting to be done mining"); new ConditionalSleep(6000, 8000) { @Override public boolean condition() { return getObjects().closest(objectModelID) != null && getObjects().closest(objectModelID).getName().equals("Ore vein"); } }.sleep(); } Tried this and it still spam clicks the ore vein
Gunman Posted May 28, 2022 Posted May 28, 2022 1 hour ago, Cod3xDev said: Tried this and it still spam clicks the ore vein Try using !ore.exists() I don't know if this will work or not, depends on how OSBot does that method
Cod3xDev Posted May 29, 2022 Posted May 29, 2022 11 hours ago, Gunman said: Try using !ore.exists() I don't know if this will work or not, depends on how OSBot does that method Still clicks the ore it's already mining