Gearfighter Posted October 12, 2016 Share Posted October 12, 2016 Hi guys, got a script that i am NEARLY done, but now it doesnt seem to wont to work at all when i start it. Can i get you guys to have a look and see what might be the cause of it not starting? cheers, Gearfighter import java.awt.Graphics2D; import org.osbot.rs07.api.Bank; import org.osbot.rs07.api.Inventory; import org.osbot.rs07.api.Mouse; import org.osbot.rs07.api.Objects; import org.osbot.rs07.api.Settings; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.input.mouse.MiniMapTileDestination; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import org.osbot.rs07.api.ui.RS2Widget; @SuppressWarnings("unused") @ScriptManifest(name = "Gearz Pizza Maker", author = "Gearfighter", version = 1.0, info = "About your script", logo = "Logo of your script. Imgur links here [DIRECT LINKS ONLY]") public class GearzPizzaMaker extends Script { public void makeAll() throws InterruptedException { RS2Widget PizzaWidget; PizzaWidget = getWidgets().get(309, 6); if (PizzaWidget != null && PizzaWidget.isVisible()) if (PizzaWidget.interact("Make all")) sleep(18000); } public void onStart() { log("Ima Make some a Pizza"); } private enum State { Bank, Banka, Bankb, Bank1, Bank1a, Pizza, Bank2, Pizza2, Bank3 } private State getState() { if (getInventory().isEmpty() && !getBank().contains("Incomplete pizza")) { return State.Bank; } if (getInventory().contains("Pizza base") && getInventory().contains("Tomato")) { return State.Pizza; } if (getInventory().contains("Incomplete pizza") && !getInventory().contains("Cheese")) { return State.Bank1; } if (getInventory().contains("Incomplete pizza") && getInventory().contains("Cheese")) { return State.Pizza2; } if (getInventory().contains("Uncooked pizza")) { return State.Bank2; } if (getBank().contains("Incomplete pizza")) { return State.Bank3; } if (getInventory().onlyContains("Tomato")) { return State.Banka; } if (getInventory().onlyContains("Pizza base")) { return State.Bankb; } if (getInventory().onlyContains("Cheese")) { return State.Bank1a; } return null; } @[member=Override] public void onExit() { // Code here will execute after the script ends // Examples: logs, listeners, or dynamic sig data. Really anything that // needs to be ended when the user of your script stops it. log("Script ended! Please leave feedback on the forums"); } @[member=Override] public int onLoop() throws InterruptedException { switch (getState()) { case Bank: if (!getBank().isOpen()) { getBank().isOpen(); getBank().withdraw("Pizza base", 14); if (getInventory().contains("Pizza base")) ; sleep(1000); getBank().withdraw("Tomato", 14); getBank().close(); } break; case Banka: if (!getBank().isOpen()) { getBank().open(); getBank().withdraw("Pizza base", 14); getBank().close(); } break; case Bankb: if (!getBank().isOpen()) { getBank().open(); getBank().withdraw("Tomato", 14); getBank().close(); } break; case Pizza: if (getInventory().getItem("Pizza base").interact("Use", "Pizza base")) if (getInventory().getItem("Tomato").interact("Use", "Tomato")) sleep(3000); makeAll(); break; case Bank1: if (!getBank().isOpen()) { getBank().open(); getBank().withdraw("Cheese", 14); getBank().close(); } break; case Bank1a: if (!getBank().isOpen()) { getBank().open(); getBank().withdraw("Incomplete pizza", 14); getBank().close(); } break; case Bank2: if (!getBank().isOpen()) { getBank().open(); getBank().depositAll(); } break; case Pizza2: if (getInventory().getItem("Incomplete pizza").interact("Use", "Incomplete pizza")) if (getInventory().getItem("Cheese").interact("Use", "Cheese")) sleep(3000); makeAll(); case Bank3: if (!getBank().isOpen()) { getBank().open(); sleep(800); getBank().withdraw("Incomplete pizza", 14); if (getInventory().contains("Incomplete pizza")); sleep(1000); getBank().withdraw("Cheese", 14); getBank().close(); } break; } return 0; } } Quote Link to comment Share on other sites More sharing options...
Auron Posted October 12, 2016 Share Posted October 12, 2016 (edited) Do some debugging, like does it loop? Does getState() return anything? It could be a problem with your logic when finding the state, so it returns null. And I'm pretty sure you can't just check whether your bank contains a certain thing if it isn't open. TBH you should redo getState completely, split it into logical steps. if (!getBank().isOpen()) { getBank().isOpen(); wat And use conditional sleeps, or at least use regular sleeps. if (!getBank().isOpen()) { getBank().open(); getBank().withdraw("Tomato", 14); getBank().close(); sleeeeeep If ya need any help holla Edited October 12, 2016 by Auron Quote Link to comment Share on other sites More sharing options...
progamerz Posted October 12, 2016 Share Posted October 12, 2016 public void makeAll() throws InterruptedException { RS2Widget PizzaWidget; PizzaWidget = getWidgets().get(309, 6); if (PizzaWidget != null && PizzaWidget.isVisible()) if (PizzaWidget.interact("Make all")) sleep(18000); } For this part i don't recommend using static widgets as sometimes if something got updated it would change the widget IDs. if (getInventory().isEmpty() && !getBank().contains("Incomplete pizza")) { return State.Bank; } The red text would return a null if the bank is not opened i think if (getBank().contains("Incomplete pizza")) { return State.Bank3; } Same for this Quote Link to comment Share on other sites More sharing options...
Alek Posted October 12, 2016 Share Posted October 12, 2016 Looks like you are missing a break after Pizza2 case. See if it that helps. Quote Link to comment Share on other sites More sharing options...
Gearfighter Posted October 13, 2016 Author Share Posted October 13, 2016 Thanks for all your help and ideas, my script is now working again! Quote Link to comment Share on other sites More sharing options...
CloudCode Posted October 17, 2016 Share Posted October 17, 2016 Thanks for all your help and ideas, my script is now working again! What exactly did you do? I am having the same issue as you and i can't seem to figure out what the problem is. Quote Link to comment Share on other sites More sharing options...
Gearfighter Posted October 18, 2016 Author Share Posted October 18, 2016 @@CloudCode I have cleaned up my code a bit since this post, if you want, private message me your code and i can help you out where i can Quote Link to comment Share on other sites More sharing options...