Jump to content

Widget doesn't exist... Need help


Mephisto

Recommended Posts

Hello everyone!

I'm trying to figure out widgets, and eventually want to get the text of a widget from a dialogue. 

This is my code: 

RS2Widget chatWidget = getWidgets().get(231, 4);
NPC npc = getNpcs().closest(Area, "Doomsayer");

if (npc!= null && npc.isVisible() && !dialogues.inDialogue()) {
    npc.interact("Talk-to");
    new ConditionalSleep(10000,500) {
        @Override
        public boolean condition() throws InterruptedException {
            return dialogues.inDialogue();
        }
    }.sleep();
    log("Im in dialogue");
    log("Waiting for widget to become visible");
    new ConditionalSleep(10000,500) {
        @Override
        public boolean condition() throws InterruptedException {
            return chatWidget != null;
        }
    }.sleep();

    if (chatWidget != null) {
        log("Widget exists");

    } else {
        log("Widget doesn't exist");
    }
}

My bot opens the dialogue which should make the widget visible, but it doesn't recognise the widget:

https://imgur.com/a/h69uvPc

Does anyone know whats going on? 

Thanks in advance!

 

Mephisto

 

Edited by Mephisto
Link to comment
Share on other sites

@Mephisto Use the debugger tool it will tell you stuff. Like actions and the message the widget displays.

Also are you using widgets for dialogue interaction? Why not use the dialogue API? Are you just using this to learn widgets?

 

EDIT: Found the issue. You're storing the widget data at the beginning and you're not updating that data.

RS2Widget chatWidget = getWidgets().get(231, 4);

^This is still null because you never updated it, and when you pull chatWidget it pulls the data before you start talking to the NPC. Hope you get what I am saying.

Edited by Gunman
  • Like 2
Link to comment
Share on other sites

20 hours ago, Gunman said:

@Mephisto Use the debugger tool it will tell you stuff. Like actions and the message the widget displays.

Also are you using widgets for dialogue interaction? Why not use the dialogue API? Are you just using this to learn widgets?

 

EDIT: Found the issue. You're storing the widget data at the beginning and you're not updating that data.


RS2Widget chatWidget = getWidgets().get(231, 4);

^This is still null because you never updated it, and when you pull chatWidget it pulls the data before you start talking to the NPC. Hope you get what I am saying.

Jup fixed the issue :) 

I indeed stored the widget data when it didn't exist yet. 

Thanks!

  • Like 1
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...