Mephisto Posted January 14, 2020 Share Posted January 14, 2020 (edited) 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 January 14, 2020 by Mephisto Quote Link to comment Share on other sites More sharing options...
Gunman Posted January 14, 2020 Share Posted January 14, 2020 (edited) @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 January 14, 2020 by Gunman 2 Quote Link to comment Share on other sites More sharing options...
Chris Posted January 14, 2020 Share Posted January 14, 2020 yeah what gunman said. Logic error 1 1 Quote Link to comment Share on other sites More sharing options...
Mephisto Posted January 15, 2020 Author Share Posted January 15, 2020 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! 1 Quote Link to comment Share on other sites More sharing options...