August 17, 201510 yr This problem has been solved. Thank you all so much for your help! I'm trying to write a very simple script to troll the Hill Giants in the Edge cave and gather Limpwerts people don't pick up. The problem is, my script just freezes the OSBot window and starts eating memory. For the life of me, I can't figure out what is going on. Here is the script: (NOTE: Bright yellow indicates edits since original post.) import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "Mustang Guy", info = "private script", name = "Limpwert root banker", version = 0.01, logo = "") public class main extends Script { @Override public void onStart() { log("Bot to pick Limpwurt roots and bank them"); } private enum State {PICK, BANK, WAIT}; private State getState() { GroundItem lr = groundItems.closest("Limpwurt root"); if (!inventory.isFull() && lr != null && lr.exists()) { return State.PICK; } if (inventory.isFull()) { return State.BANK; } return State.WAIT; } @Override public int onLoop() throws InterruptedException { GroundItem lr = groundItems.closest("Limpwurt root"); switch (getState()) { case PICK: log("PICK"); if (lr != null && lr.exists()) lr.interact("Take"); break; case BANK: log("BANK"); //write script to run to bank break; case WAIT: log("WAIT"); sleep(random(500, 700)); break; } return random(200, 300); } @Override public void onExit() { log("adios"); } @Override public void onPaint(Graphics2D g) {} } Edited August 17, 201510 yr by mustang guy
August 17, 201510 yr private State getState() { GroundItem lr = groundItems.closest("Limpwert root"); if (!inventory.isFull() && lr.exists()) return State.PICK; if (inventory.isFull()) return State.BANK; return State.WAIT; } Change to private State getState() { GroundItem lr = groundItems.closest("Limpwert root"); if (!inventory.isFull() && lr.exists()){ return State.PICK; } if (inventory.isFull()){ return State.BANK; } return State.WAIT; } Also you have nothing in your bank statement, so it'll sit there and shit itself if state = bank. Edited August 17, 201510 yr by Gilgad
August 17, 201510 yr Author I put the brackets in the getState() and changed the spelling of Limpwurt, and it still freezes and gobbles memory. I edited the script above to reflect those changes, and they are indicated in bright yellow. I threw a bunch of log statements in the script in the various case sections so I could figure out which section the error is occurring in. The problem is, the text window below the OSBot screen is too short to see the errors and logs() and the window is frozen so I can't scroll back up. I couldn't find a debug function for writing the log to a file. Here is all I can see in the error log below the RS window in the OSBot app: Edited August 17, 201510 yr by mustang guy
August 17, 201510 yr you must always null check, instead of .exists do lr != null this will stop the NPE.
August 17, 201510 yr Author you must always null check, instead of .exists do lr != null this will stop the NPE. You nailed it Precise. I was null checking in the loop, but overlooked it in the getState(). By the way, the script works great. Perhaps instead of having the script pick up the limp, I will have it notify me there is one laying down somewhere in the room. That way I can pick it up and not be in any danger of getting nabbed for scripting. What I want is to have this little baby running while I am killing Hill giants. Edited August 18, 201510 yr by mustang guy
August 18, 201510 yr You nailed it Precise. I was null checking in the loop, but overlooked it in the getState(). By the way, the script works great. Perhaps instead of having the script pick up the limp, I will have it notify me there is one laying down somewhere in the room. That way I can pick it up and not be in any danger of getting nabbed for scripting. What I want is to have this little baby running while I am killing Hill giants. If you run in injection mode you could get done for using "3rd party clients". Go big or go home lol
Create an account or sign in to comment