Gearfighter Posted October 11, 2016 Share Posted October 11, 2016 Im making a Pizza maker script but i cant get it to interact with the widget. it just goes to the next state 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 onStart() { log("Ima Make some a Pizza"); } private enum State { Bank, Bank1, Pizza, Bank2, Pizza2 } private State getState() { if (inventory.isEmpty()) { return State.Bank; } if (getInventory().getAmount("Pizza base") == 14 && (getInventory().getAmount("Tomato") == 14)) { return State.Pizza; } if (getInventory().getAmount("Incomplete pizza") == 14) { return State.Bank1; } if (inventory.contains("Incomplate pizza", "Cheese")) { return State.Pizza2; } if (inventory.contains("Uncooked pizza")) ; return State.Bank2; } @[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().open(); getBank().withdraw("Pizza base", 14); if (getInventory().getAmount("Pizza base") == 14) getBank().withdraw("Tomato", 14); getBank().close(); } break; case Pizza: RS2Widget PizzaWidget; PizzaWidget = getWidgets().get(309, 6); if (getInventory().getAmount("Pizza base") == 14) if (getInventory().getAmount("Tomato") == 14) if (getInventory().getItem("Pizza base").interact("Use", "Pizza base")) if (getInventory().getItem("Tomato").interact("Use", "Tomato")) if (PizzaWidget != null && PizzaWidget.isVisible()) { if (PizzaWidget.interact("Make all")) new ConditionalSleep(50000) { // not sure // how you // want to // do this // but this // is how u // implement // conditional // sleeps @[member=Override] public boolean condition() throws InterruptedException { return getInventory().getAmount("Incomplete pizza") == 14; // if // true // stop // sleeping..helpful // to // combat // latency..(lagg // etc) } }.sleep(); break; } case Bank1: if (inventory.contains("Incomplete pizza")) ; if (!getBank().isOpen()) { getBank().open(); getBank().withdraw("Cheese", 14); break; } case Bank2: if (inventory.contains("Uncooked pizza")) ; if (!getBank().isOpen()) { getBank().open(); getBank().depositAll(); break; } case Pizza2: PizzaWidget = getWidgets().get(309, 6); if (inventory.contains("Incomplete pizza", "Cheese")) ; if (getInventory().getItem("Incomplete pizza").interact("Use", "Incomplete pizza")) if (getInventory().getItem("Cheese").interact("Use", "Cheese")) ; if (PizzaWidget != null) PizzaWidget.interact("Make all"); break; } return 0; } private void sleep(int i, int j) { // TODO Auto-generated method stub } } anything to help make it better and for me to learn would be greatly appreciated Quote Link to comment Share on other sites More sharing options...
Isolate Posted October 11, 2016 Share Posted October 11, 2016 We're often re-informed not to use static ids. Maybe something along the lines of.. RS2Widget allWidget = getWidgets().singleFilter(getWidgets().getAll(), new ActionFilter("Make All")); Might help out. I'd usually test code before posting it but it seems jamflex caught up with my test alt I'd also like to make a mention all the things containing == 14. I'm unsure if it works the same in cooking prep where a level can break the task series (or even if this action gives xp). But it seems wiser to make a "Can prepare" boolean which checks if you have atleast one of each, then your conditions and sleep condition can be "can prepare" and until "Not can prepare" and in a random case which may break your flow you wont bank when you could still make more. 1 Quote Link to comment Share on other sites More sharing options...