Jump to content
Sign in to follow this  
Mountain Troll

[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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
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.

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...