Explv Posted August 5, 2017 Posted August 5, 2017 (edited) Alternative much simpler snippet provided by @Deceiver getKeyboard().typeString("::toggleroofs"); If you still want to use the widget interaction way: This makes use of my CachedWidget class: https://osbot.org/forum/topic/97399-a-better-way-to-handle-widgets-cachedwidget/ And also my WidgetActionFilter class: https://osbot.org/forum/topic/127248-widget-action-filter/ import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.event.Event; public final class ToggleRoofsHiddenEvent extends Event { private final CachedWidget advancedOptionsWidget = new CachedWidget("Advanced options"); private final CachedWidget displaySettingsWidget = new CachedWidget(new WidgetActionFilter("Display")); private final CachedWidget toggleRoofHiddenWidget = new CachedWidget(new WidgetActionFilter("Roof-removal")); @Override public final int execute() throws InterruptedException { if (Tab.SETTINGS.isDisabled(getBot())) { setFailed(); } else if (getTabs().getOpen() != Tab.SETTINGS) { getTabs().open(Tab.SETTINGS); } else if (!advancedOptionsWidget.get(getWidgets()).isPresent()) { displaySettingsWidget.get(getWidgets()).ifPresent(widget -> widget.interact()); } else if (!toggleRoofHiddenWidget.get(getWidgets()).isPresent()) { advancedOptionsWidget.get(getWidgets()).get().interact(); } else if (toggleRoofHiddenWidget.get(getWidgets()).get().interact()) { setFinished(); } return 200; } } Usage: if (!getSettings().areRoofsEnabled()) { Event toggleRoofsHiddenEvent = new ToggleRoofsHiddenEvent(); execute(toggleRoofsHiddenEvent); } Edited August 9, 2017 by Explv 3
Deceiver Posted August 5, 2017 Posted August 5, 2017 getKeyboard().typeString("::toggleroofs", true); 2
Explv Posted August 9, 2017 Author Posted August 9, 2017 On 05/08/2017 at 8:04 PM, Deceiver said: getKeyboard().typeString("::toggleroofs", true); Wow, TIL, I had no idea osrs had chatbox commands. Thanks kiddo 1
Deceiver Posted August 9, 2017 Posted August 9, 2017 29 minutes ago, Explv said: Wow, TIL, I had no idea osrs had chatbox commands. Thanks kiddo ANYTHING TO MAKE YOU PROUD SENSEI
Alek Posted August 9, 2017 Posted August 9, 2017 There's already a CachedWidget class that I wrote two years ago though?
Explv Posted August 9, 2017 Author Posted August 9, 2017 37 minutes ago, Alek said: There's already a CachedWidget class that I wrote two years ago though? There is, I just wanted to write it in my own style, without passing MethodProvider as a constructor argument, with a few extra constructors, and without having to explicitly call cache() before getWidget(). I could have just extended yours, but whatever. 1