July 6, 20178 yr I'm just starting to learn to work with the API and I'm at a roadblock. I'm trying to create a script for tut island but it's throwing me an error: package rootTutorial; import java.awt.*; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "shelledroot", info = "Tutorial Runner", name = "rootTutorial", version = 0.1, logo = "") public class main extends Script { @Override public void onStart() { log("Tutorial Island script!"); } @Override public int onLoop() throws InterruptedException { // TODO Auto-generated method stub if(getWidgets().getWidgetContainingText("Accept") != null) { getWidgets().getWidgetContainingText("Accept").interact("Accept"); } return 0; } @Override public void onExit(){ log("Script has finished! Go get those 7 QP you need!"); } @Override public void onPaint(Graphics2D g) { // Drawing a simple message to the screen canvas g.drawString("Hello World", 400, 250); } } It completes clicking the Accept button in the widget but somehow: if(getWidgets().getWidgetContainingText("Accept") != null) Still returns true afterwards.. Is this some Jagex trickery or am I just plain dumb (both could be very possible). After clicking it the loop should restart from the top and the test should be false right? Edited July 6, 20178 yr by shelledroot
July 6, 20178 yr Author 24 minutes ago, HeyImJamie said: Check if it's visible sooo: if(getWidgets().getWidgetContainingText("Accept") != null && getWidgets().isVisible(widgetRoot#, widgetChild#) == true) ? Edited July 6, 20178 yr by shelledroot
July 6, 20178 yr 14 minutes ago, shelledroot said: sooo: if(getWidgets().getWidgetContainingText("Accept") != null && getWidgets().isVisible(widgetRoot#, widgetChild#) == true) ? if (getWidgets().getWidgetContainingText("Accept") != null && getWidgets().getWidgetContainingText("Accept").isVisible() { // do shit }
July 6, 20178 yr Author 1 minute ago, HeyImJamie said: if (getWidgets().getWidgetContainingText("Accept") != null && getWidgets().getWidgetContainingText("Accept").isVisible() { // do shit } Thanks that works. New at using an API (other then REST API's), and being off java for a few years. This should probably get me a long way. You have my thanks and a like.
Create an account or sign in to comment