mitsuki Posted September 3, 2020 Share Posted September 3, 2020 Hey guys, I've been working on a script that cooks at the lumbridge kitchen (after cooks assistant quest). The script works, but the two main problems I have with it are as follows: 1. When it clicks on "Raw shrimps" in the inventory, it seems to freeze, and doesn't use it with the range for like 8+ seconds, which seems really bot like. 2. When the widget comes up over the dialogue box, it doesn't detect it, so it uses the raw shrimps with the range a second time, then detects it. Anyone know why it is doing this? I thought my code seemed fine? Below is my script, thank you in advance dudes. import javax.swing.JOptionPane; import org.osbot.rs07.accessor.XInteractableObject; import org.osbot.rs07.api.Bank; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.utility.ConditionalSleep; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.Inventory; import org.osbot.rs07.api.model.Item; import org.osbot.rs07.api.Keyboard; import org.osbot.rs07.script.API; import org.osbot.rs07.api.Dialogues; import org.osbot.rs07.api.Widgets; import java.awt.*; import java.awt.event.KeyEvent; import org.osbot.rs07.api.Dialogues; @ScriptManifest(author = "Mitsuki", info = "CodeTest", name = "CodeTest", version = 0, logo = "") public class Main extends Script { public Area lumbridgeKitchen = new Area(3206, 3212, 3211, 3216); private RS2Widget getMyWidget() { RS2Widget cookShrimpWidget = getWidgets().get(270, 14); return cookShrimpWidget; } private boolean isMyWidgetWorking() { return getMyWidget() != null && getMyWidget().isVisible(); } @Override public void onStart() { log("Let's get started!"); } @Override public int onLoop() throws InterruptedException { if (lumbridgeKitchen.contains(myPlayer()) && getInventory().contains("Raw shrimps")) { getInventory().getItem("Raw shrimps").interact("Use"); if (getInventory().isItemSelected() == true) { RS2Object range = getObjects().closest("Cooking range"); range.interact("Use"); if (isMyWidgetWorking()) { log("Widget time"); getMyWidget().interact("Cook"); } } } return random(5000, 10000); } @Override public void onExit() { log("Thanks for running my AutoShrimper!"); } } Btw, all of the imports are there, even though they aren't being used, as this is my testcode file. Quote Link to comment Share on other sites More sharing options...
ez11 Posted September 3, 2020 Share Posted September 3, 2020 (edited) 1. the return value is how long the script waits between the loops, so every time your script loops its going to wait for 5-10sec based on your code. 2. You have no sleeps at all in your script so it will try to do everything as soon as possible but it takes a minimum of 1tick (0.6s) before anything changes ingame for most things, so your 2nd if statement is simply going to be false on the first loop read this, especially the sleep part Edited September 3, 2020 by ez11 1 Quote Link to comment Share on other sites More sharing options...
mitsuki Posted September 3, 2020 Author Share Posted September 3, 2020 5 minutes ago, ez11 said: 1. the return value is how long the script waits between the loops, so every time your script loops its going to wait for 5-10sec based on your code. 2. You have no sleeps at all in your script so it will try to do everything as soon as possible but it takes a minimum of 1tick (0.6s) before anything changes ingame for most things, so your 2nd if statement is simply going to be false on the first loop read this, especially the sleep part okay, thank you for the advice! PS. did you learn java before writing scripts? or did you learn through this? Cheers, Mitsuki Quote Link to comment Share on other sites More sharing options...
ez11 Posted September 3, 2020 Share Posted September 3, 2020 Just now, mitsuki said: did you learn java before writing scripts? I read java tutorials so i could start with scripting Quote Link to comment Share on other sites More sharing options...
ProjectPact Posted September 3, 2020 Share Posted September 3, 2020 1 hour ago, mitsuki said: okay, thank you for the advice! PS. did you learn java before writing scripts? or did you learn through this? Cheers, Mitsuki Script Factory is your friend. Check it out. 1 Quote Link to comment Share on other sites More sharing options...
Space Posted September 3, 2020 Share Posted September 3, 2020 13 minutes ago, ProjectPact said: Script Factory is your friend. Check it out. Free advertisement but I agree, With everything built in and it's super easy to use w/ tutorials readily available, I'd recommend. As well as the ability to use other users scripts. Can't go wrong. 1 Quote Link to comment Share on other sites More sharing options...
mitsuki Posted September 3, 2020 Author Share Posted September 3, 2020 3 hours ago, ProjectPact said: Script Factory is your friend. Check it out. wasted advertisement here mate, I already own it and it is really good, I just want to actually learn how to write scripts myself, as script factory doesn't allow you to export the scripts Quote Link to comment Share on other sites More sharing options...