mustang guy Posted August 17, 2015 Share Posted August 17, 2015 (edited) 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, 2015 by mustang guy Quote Link to comment Share on other sites More sharing options...
Gilgad Posted August 17, 2015 Share Posted August 17, 2015 (edited) 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, 2015 by Gilgad Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted August 17, 2015 Share Posted August 17, 2015 I'm pretty sure it's Limpwurt root, dunno what's causing osbot to crash tho... Quote Link to comment Share on other sites More sharing options...
Worthwhile Posted August 17, 2015 Share Posted August 17, 2015 Also, shouldn't it be limpwurt and not limpwert? Quote Link to comment Share on other sites More sharing options...
mustang guy Posted August 17, 2015 Author Share Posted August 17, 2015 (edited) 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, 2015 by mustang guy Quote Link to comment Share on other sites More sharing options...
Precise Posted August 17, 2015 Share Posted August 17, 2015 you must always null check, instead of .exists do lr != null this will stop the NPE. 1 Quote Link to comment Share on other sites More sharing options...
mustang guy Posted August 17, 2015 Author Share Posted August 17, 2015 (edited) 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, 2015 by mustang guy 1 Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted August 18, 2015 Share Posted August 18, 2015 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 Quote Link to comment Share on other sites More sharing options...