Magerange Posted May 9, 2017 Share Posted May 9, 2017 (edited) So I wrote a local script with Eclipse and tried to export it as a .jar file to run it. The problem is that it does not start. When I select it in OSBot, it does nothing. My guess is that it has something to do with JRE versions not mathcing (1.7 compared to 1.8), but since I am a newbie with this, maybe someone can take me through how to check this propertly...? Should I just clean my PC from Java and install JRE 1.7? Much appreciated Edited May 9, 2017 by Magerange Quote Link to comment Share on other sites More sharing options...
Token Posted May 9, 2017 Share Posted May 9, 2017 You most likely attempted to initialize an instance of any OSBot class outside the methods defined in the Script class, eg: @ScriptManifest(name = "Lol", author = "Token", version = 1.0, info = "", logo = "") public class Lol extends Script { NPC x = npcs.closest("Guard"); // script won't start because of this NPC y; @Override public void onStart() throws InterruptedException { // something y = npcs.closest("Guard"); // but this is fine } @Override public int onLoop() throws InterruptedException { // something return 69; } } Post your code if that's not the case because this is definitely a programming error Quote Link to comment Share on other sites More sharing options...
Magerange Posted May 9, 2017 Author Share Posted May 9, 2017 10 minutes ago, Token said: You most likely attempted to initialize an instance of any OSBot class outside the methods defined in the Script class, eg: @ScriptManifest(name = "Lol", author = "Token", version = 1.0, info = "", logo = "") public class Lol extends Script { NPC x = npcs.closest("Guard"); // script won't start because of this NPC y; @Override public void onStart() throws InterruptedException { // something y = npcs.closest("Guard"); // but this is fine } @Override public int onLoop() throws InterruptedException { // something return 69; } } Post your code if that's not the case because this is definitely a programming error Alright, so here is what I've been working on: @ScriptManifest(author = "Magerange", name = "JugFiller", info = "Fills jugs with water in east Falador", version = 1.0, logo = "") public final class Main extends Script { private final Area Pump = new Area (2947, 3382, 2948, 3383); @Override public final int onLoop() throws InterruptedException { if (canFill()){ fill(); } else { bank(); } return random(175, 270); } private boolean canFill() { return getInventory().contains("Jug"); } private boolean pumpUsable(){ return Pump.contains(myPlayer()); } Entity wPump = getObjects().closest("Waterpump"); private void fill() { if (!Pump.contains(myPosition())){ getWalking().webWalk(Pump); } else if (pumpUsable()) { if (wPump != null) inventory.interact("Use","Jug"); wPump.interact("Use"); } else { new ConditionalSleep(1500) { @Override public boolean condition() { return myPlayer().isAnimating(); } }.sleep(); } } private void bank() throws InterruptedException { if(!Banks.FALADOR_EAST.contains(myPosition())) { getWalking().webWalk(Banks.FALADOR_EAST); } else if (!getBank().isOpen()) { getBank().open(); } else if (!getInventory().isEmptyExcept("Jug")) { getBank().depositAll(); } else if (getBank().contains("Jug")) { getBank().withdrawAll("Jug"); } else { stop(true); } } } Quote Link to comment Share on other sites More sharing options...
Token Posted May 9, 2017 Share Posted May 9, 2017 4 minutes ago, Magerange said: Alright, so here is what I've been working on: @ScriptManifest(author = "Magerange", name = "JugFiller", info = "Fills jugs with water in east Falador", version = 1.0, logo = "") public final class Main extends Script { private final Area Pump = new Area (2947, 3382, 2948, 3383); @Override public final int onLoop() throws InterruptedException { if (canFill()){ fill(); } else { bank(); } return random(175, 270); } private boolean canFill() { return getInventory().contains("Jug"); } private boolean pumpUsable(){ return Pump.contains(myPlayer()); } Entity wPump = getObjects().closest("Waterpump"); private void fill() { if (!Pump.contains(myPosition())){ getWalking().webWalk(Pump); } else if (pumpUsable()) { if (wPump != null) inventory.interact("Use","Jug"); wPump.interact("Use"); } else { new ConditionalSleep(1500) { @Override public boolean condition() { return myPlayer().isAnimating(); } }.sleep(); } } private void bank() throws InterruptedException { if(!Banks.FALADOR_EAST.contains(myPosition())) { getWalking().webWalk(Banks.FALADOR_EAST); } else if (!getBank().isOpen()) { getBank().open(); } else if (!getInventory().isEmptyExcept("Jug")) { getBank().depositAll(); } else if (getBank().contains("Jug")) { getBank().withdrawAll("Jug"); } else { stop(true); } } } It's exactly what I said, you initialized wPump outside the Script methods 1 Quote Link to comment Share on other sites More sharing options...
Magerange Posted May 9, 2017 Author Share Posted May 9, 2017 5 minutes ago, Token said: It's exactly what I said, you initialized wPump outside the Script methods Thanks! Should I make a new method for it? Quote Link to comment Share on other sites More sharing options...
Container Posted May 9, 2017 Share Posted May 9, 2017 10 minutes ago, Magerange said: Alright, so here is what I've been working on: @ScriptManifest(author = "Magerange", name = "JugFiller", info = "Fills jugs with water in east Falador", version = 1.0, logo = "") public final class Main extends Script { private final Area Pump = new Area (2947, 3382, 2948, 3383); @Override public final int onLoop() throws InterruptedException { if (canFill()){ fill(); } else { bank(); } return random(175, 270); } private boolean canFill() { return getInventory().contains("Jug"); } private boolean pumpUsable(){ return Pump.contains(myPlayer()); } Entity wPump = getObjects().closest("Waterpump"); private void fill() { if (!Pump.contains(myPosition())){ getWalking().webWalk(Pump); } else if (pumpUsable()) { if (wPump != null) inventory.interact("Use","Jug"); wPump.interact("Use"); } else { new ConditionalSleep(1500) { @Override public boolean condition() { return myPlayer().isAnimating(); } }.sleep(); } } private void bank() throws InterruptedException { if(!Banks.FALADOR_EAST.contains(myPosition())) { getWalking().webWalk(Banks.FALADOR_EAST); } else if (!getBank().isOpen()) { getBank().open(); } else if (!getInventory().isEmptyExcept("Jug")) { getBank().depositAll(); } else if (getBank().contains("Jug")) { getBank().withdrawAll("Jug"); } else { stop(true); } } } As Token said; I'd move the initialization of wPump to the fill() method. 1 Quote Link to comment Share on other sites More sharing options...
Token Posted May 9, 2017 Share Posted May 9, 2017 15 minutes ago, Magerange said: Thanks! Should I make a new method for it? Just initialize it inside a method when you actually need it 1 Quote Link to comment Share on other sites More sharing options...
Magerange Posted May 9, 2017 Author Share Posted May 9, 2017 Thanks to both of you! It works now. However, I have found out that my conditionalsleep does not function propertly. I think I have set wrong parameter for it, because the account doesn't always animate while filling jugs. How could I replace it so it sleeps for x miliseconds? Do I have to change a lot of code? Quote Link to comment Share on other sites More sharing options...
dmmslaver Posted May 10, 2017 Share Posted May 10, 2017 (edited) If there is an error before the onStart method is called it will simply not log the error and leave you clueless. Make sure there is no code executing before the onStart method that accesses any osbot library, such as during variable initialization. It's simply throwing NPE and suppressing the error.. Not your fault, bad programming on the APIs part not logging those exceptions. Edited May 10, 2017 by dmmslaver Quote Link to comment Share on other sites More sharing options...