lisabe96 Posted January 19, 2016 Posted January 19, 2016 How would I handle inputting an amount when you click the X-option. The dialogues class didn't bring me any solution, neither did configs and I don't really know where else to look.
Fruity Posted January 19, 2016 Posted January 19, 2016 (edited) widgets and keyboard if dialogs doesn't have it Edited January 19, 2016 by Fruity 1
Extreme Scripts Posted January 19, 2016 Posted January 19, 2016 (edited) if(xWidget != null && xWidget.isVisible()){ getKeyboard().typeString("I like vaginas."); } Edited January 19, 2016 by Extreme Scripts 1
Kalispel Posted January 19, 2016 Posted January 19, 2016 No offense, but shouldn't scripter 1 be able to at least know how to use widgets?
lisabe96 Posted January 19, 2016 Author Posted January 19, 2016 No offense, but shouldn't scripter 1 be able to at least know how to use widgets? Use sure, thinking about it is another thing As this is dialogue related to me I was thinking dialogues and not widgets. Will try to get it working with widgets in a bit
Kalispel Posted January 19, 2016 Posted January 19, 2016 Use sure, thinking about it is another thing As this is dialogue related to me I was thinking dialogues and not widgets. Will try to get it working with widgets in a bit Its all good though mate. You earned your rank.
lisabe96 Posted January 19, 2016 Author Posted January 19, 2016 RS2Widget w = getWidgets().get(162, 31); if (w == null) { log("Widget not found"); break; } if (w.isVisible()) { getKeyboard().typeString("5"); } Works perfectly, thanks for the help guys
Apaec Posted January 19, 2016 Posted January 19, 2016 No offense, but shouldn't scripter 1 be able to at least know how to use widgets? Scripter 1 is there for a reason - it's a great platform to build your knowledge on. Besides, you can make completely reasonable and functional scripts without widgets. You've got to learn it somewhere! 2
Zappster Posted January 20, 2016 Posted January 20, 2016 (edited) RS2Widget w = getWidgets().get(162, 31); if (w == null) { log("Widget not found"); break; } if (w.isVisible()) { getKeyboard().typeString("5"); } Works perfectly, thanks for the help guys FYI, in this case. If the interface is null, it's also not visible. if(w != null) getKeyboard().typeString("5"); else log("Widget not found"); will also work. Edited January 20, 2016 by Zappster
lisabe96 Posted January 20, 2016 Author Posted January 20, 2016 FYI, in this case. If the interface is null, it's also not visible. if(w != null) getKeyboard().typeString("5"); else log("Widget not found"); will also work. Don't kill me when I'm wrong but with isVisible(); I'm assuming it's actually visible on the screen. This means that the widget might not be null, but because of e.g. lag it's not visible instantly yet. So checking if it's visible would be a good thing over only checking if it's not null. 2
Zappster Posted January 20, 2016 Posted January 20, 2016 Don't kill me when I'm wrong but with isVisible(); I'm assuming it's actually visible on the screen. This means that the widget might not be null, but because of e.g. lag it's not visible instantly yet. So checking if it's visible would be a good thing over only checking if it's not null. Fine example of "A programemr will look both ways before crossing a one way street" lol. I've used this in my scripts and I don't get the problem. In some cases, you can have a wdiget that is there and not ready to show (such as in Zeah, the family stats are hidden but not null and still readable). However, in this case and with all cases of chat box interfaces, I believe the widget is created with the .isVisible set to true at all time and will never have a return of false. This is purely from my personal experience. I've not once had a moment in which the player typed in the chatbox before sending the message.
Acerd Posted January 20, 2016 Posted January 20, 2016 No offense, but shouldn't scripter 1 be able to at least know how to use widgets? @KEVzilla is Scripter II and doesn't know how to use Widgets
Joseph Posted January 22, 2016 Posted January 22, 2016 (edited) RS2Widget w = getWidgets().get(162, 31); if (w == null) { log("Widget not found"); break; } if (w.isVisible()) { getKeyboard().typeString("5"); } Works perfectly, thanks for the help guys you should really null check that widget before calling its isVisible(). incase you think you did. I have to tell you, you didn't. The idea: RS2Widget wid = getWidget(#,#); if (wid == null) { //the widget is null } else { //its not null if (wid.isVisible()) { //whatever........ } } here the method I use public boolean canEnterAmount() { RS2Widget w = getWidgets().getWidgetContainingText(162, "Enter amount:"); return w != null && w.isVisible(); } //this is what I normally do if (!canEnterAmount()) { //interact with something until it pops up } else { getKeyboard().typeString("5", canEnterAmount()); } that Boolean after the "5" is there as a failsafe so incase you type in the chatbox. The message doesn't get sent out Edited January 22, 2016 by Joseph
matt123337 Posted January 23, 2016 Posted January 23, 2016 you should really null check that widget before calling its isVisible(). incase you think you did. I have to tell you, you didn't. But he did. Going by the code he posted he's using that in some sorta loop, and breaks out of it if it's null... 1