Jump to content

Nooby question regarding Widget text


Recommended Posts

Posted (edited)

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 by shelledroot
Posted
1 minute ago, HeyImJamie said:

if (getWidgets().getWidgetContainingText("Accept") != null && getWidgets().getWidgetContainingText("Accept").isVisible() {
	// do shit
}

 

Thanks that works. :D

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

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...