Toxic Posted February 4, 2018 Share Posted February 4, 2018 Well, I really didn't want to ask for help and try to figure this out myself but...I just don't understand why my script is not running. I click start and it just stands there by the jug...:/ If anyone can help and explain too me how to fix this to make it take the Jug in lumbridge kitchen and then drop and wait....please I would love you. Here is my Code Spoiler import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.model.RS2Object; import java.awt.*; @ScriptManifest(author = "Toxic", info = "My first script", name = "Lumbridge Jug Stealer", version = 0, logo = "") public class Main extends Script { @Override public void onStart() { log("Welcome to Toxic's Jug Stealer."); log("This is my first sript ever, hope you enjoy!"); } private enum State { TAKE, DROP, WAIT }; private State getState() { RS2Object Table = getObjects().closest("Jug"); if (!inventory.isEmpty()) return State.DROP; if (Table != null) return State.TAKE; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case TAKE: RS2Object Table = getObjects().closest("Jug"); if (Table != null) { Table.interact("Take"); } break; case DROP: inventory.dropAll(); break; case WAIT: sleep(random(500, 700)); break; } return random(200, 300); } @Override public void onExit() { log("Thanks for running my Jug Stealer!"); } @Override public void onPaint(Graphics2D g) { g.drawString("Hello Jugs!", 50, 50); } } Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted February 4, 2018 Share Posted February 4, 2018 It's possible the RS2Object call within your getState method is stopping it from running. Try with the script logged in. If that fixes it you could add a while loop to your onStart method that waits for the script to be logged in before your getState method is called Quote Link to comment Share on other sites More sharing options...
Toxic Posted February 4, 2018 Author Share Posted February 4, 2018 4 minutes ago, HeyImJamie said: It's possible the RS2Object call within your getState method is stopping it from running. Try with the script logged in. If that fixes it you could add a while loop to your onStart method that waits for the script to be logged in before your getState method is called I am already logged in while starting the script and it does nothing still. Quote Link to comment Share on other sites More sharing options...
Stimpack Posted February 5, 2018 Share Posted February 5, 2018 (edited) jug is a GroundItem edit: btw you search for a jug twice (getState / TAKE case), maybe you could cache it Edited February 5, 2018 by Stimpack Quote Link to comment Share on other sites More sharing options...
Toxic Posted February 5, 2018 Author Share Posted February 5, 2018 @HeyImJamie Helped me with it all on teamviewer Also showed me a bunch of other stuff...love this guy haha. Will be doing pseudo code from now on 1 Quote Link to comment Share on other sites More sharing options...
Juggles Posted February 5, 2018 Share Posted February 5, 2018 Super bowl is on. No coding. 1 Quote Link to comment Share on other sites More sharing options...
Toxic Posted February 5, 2018 Author Share Posted February 5, 2018 16 minutes ago, Juggles said: Super bowl is on. No coding. Your right, I apologize Quote Link to comment Share on other sites More sharing options...
Prozen Posted February 5, 2018 Share Posted February 5, 2018 You're trying to grab the nearest Object, when jugs are grounditems. use getGroundItems().closest() as I use in the example. GroundItem jug = getGroundItems().closest("Jug"); if(jug != null && jug.exists() && jug.interact("Take")) { // Interaction successful - sleep here } Quote Link to comment Share on other sites More sharing options...
Toxic Posted February 5, 2018 Author Share Posted February 5, 2018 9 hours ago, Prozen said: You're trying to grab the nearest Object, when jugs are grounditems. use getGroundItems().closest() as I use in the example. GroundItem jug = getGroundItems().closest("Jug"); if(jug != null && jug.exists() && jug.interact("Take")) { // Interaction successful - sleep here } Got it, Thank you Quote Link to comment Share on other sites More sharing options...