Jump to content

[Resolved] Widgets - Containing text on settings


Recommended Posts

Posted (edited)

Im trying to make my script more friendly by making it search for the widgets rather than using fixed ids, after a while on the api i found getWidgetContainingText, so i went to the code that changes the settings on start. Im trying to change the roof setting, so the first widget it goes for is the Display tab, but with some testing if the chat tab is open it will go towards the display name option.

image.png.c1d53d4add2b443ff3729e68b746ecae.png

Is there any other method i could use without using a widget list?

Edit: Started messing with the widget debugger and found its sprite id :)

Edited by Mountain Troll
Posted (edited)
10 minutes ago, Mountain Troll said:

Im trying to make my script more friendly by making it search for the widgets rather than using fixed ids, after a while on the api i found getWidgetContainingText, so i went to the code that changes the settings on start. Im trying to change the roof setting, so the first widget it goes for is the Display tab, but with some testing if the chat tab is open it will go towards the display name option.

image.png.c1d53d4add2b443ff3729e68b746ecae.png

Is there any other method i could use without using a widget list?

I'm not entirely sure what your exact question is so I'm not sure if my reply will answer it.

Look into filters.

e.g.:

public class WidgetMessagesFilter implements Filter<RS2Widget> {

    private final String[] messages;

    public WidgetMessagesFilter(final String... messages) {
        this.messages = messages;
    }

    @Override
    public final boolean match(final RS2Widget rs2Widget) {
        if (rs2Widget == null || !rs2Widget.isVisible() || rs2Widget.getMessage() == null) {
            return false;
        }

        return Arrays.stream(messages).anyMatch(m -> rs2Widget.getMessage().contains(m));
    }
}

Usage:

final RS2Widget loveEagleFilter = s.getWidgets().singleFilter(s.getWidgets().getAll(), new WidgetMessageFilter("TEXT HERE"));

 

Edited by Eagle Scripts
Posted
35 minutes ago, Eagle Scripts said:

I'm not entirely sure what your exact question is so I'm not sure if my reply will answer it.

Look into filters.

e.g.:


public class WidgetMessagesFilter implements Filter<RS2Widget> {

    private final String[] messages;

    public WidgetMessagesFilter(final String... messages) {
        this.messages = messages;
    }

    @Override
    public final boolean match(final RS2Widget rs2Widget) {
        if (rs2Widget == null || !rs2Widget.isVisible() || rs2Widget.getMessage() == null) {
            return false;
        }

        return Arrays.stream(messages).anyMatch(m -> rs2Widget.getMessage().contains(m));
    }
}

Usage:


final RS2Widget loveEagleFilter = s.getWidgets().singleFilter(s.getWidgets().getAll(), new WidgetMessageFilter("TEXT HERE"));

 

Thank you, although i found a different solution the help is appriciated. :)

  • Like 1
Posted
7 minutes ago, Eagle Scripts said:

No problem at all. Mind sharing the solution with us?

Of course i dont mind. I think it was more of my own error as i was looking for a widget using text when there wasnt any. I had read about using sprite ids but had no clue how to get them, when i was just messing with the client options i found the widget debuggeder and then a way to find the sprite ids.

All in all i believe is was my fault for not fully reading into what i was doing.

  • Like 1

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...