Jump to content

Nooby question regarding Widget text


shelledroot

Recommended Posts

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
Link to comment
Share on other sites

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
}

 

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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