March 29, 20187 yr Hello Guys, i have some problems opening the POH menu. Sometimes this code works and sometimes it does not. I think the problem is when to sleep and maybe that the sleep times are to short. Can some1 help me please? public boolean callServant() { if(s.getTabs().getOpen() != Tab.INVENTORY) { s.getTabs().open(Tab.INVENTORY); } s.log("Open Settings Tab."); if(s.getTabs().open(Tab.SETTINGS)) { Sleep.sleepUntil(()-> s.getTabs().getOpen() == Tab.SETTINGS, 5000); s.log("Settings Tab opened."); Sleep.sleepUntil(()-> s.getWidgets().get(261, 71) != null && s.getWidgets().get(261,71).isVisible(), 10000); s.log("Try to open House options"); if(s.getWidgets().get(261,71).interact()) { s.log("Houuse options opened."); Sleep.sleepUntil(()-> s.getWidgets().get(370,19) != null && s.getWidgets().get(370, 19).isVisible(), 10000); s.log("Calling servant."); if(s.getWidgets().get(370,19).interact()) { s.log("Servant called!"); return true; } } } return false; }
March 29, 20187 yr The issue is that you're trying to interact inside the if statement that opens the settings tab, so you're only going to be executing that code whenever you open the settings tab. 17 minutes ago, su1ts said: Hello Guys, i have some problems opening the POH menu. Sometimes this code works and sometimes it does not. I think the problem is when to sleep and maybe that the sleep times are to short. Can some1 help me please? public boolean callServant() { if(s.getTabs().getOpen() != Tab.INVENTORY) { s.getTabs().open(Tab.INVENTORY); } s.log("Open Settings Tab."); if (settings tab is open) { s.log("Try to open House options"); if (house options are open) { if(s.getWidgets().get(370,19).interact()) { s.log("Servant called!"); return true; } } else { if(s.getWidgets().get(261,71).interact()) { s.log("Houuse options opened."); Sleep.sleepUntil(()-> s.getWidgets().get(370,19) != null && s.getWidgets().get(370, 19).isVisible(), 10000); s.log("Calling servant."); } } } else { if(s.getTabs().open(Tab.SETTINGS)) { Sleep.sleepUntil(()-> s.getTabs().getOpen() == Tab.SETTINGS, 5000); s.log("Settings Tab opened."); Sleep.sleepUntil(()-> s.getWidgets().get(261, 71) != null && s.getWidgets().get(261,71).isVisible(), 10000); } return false; } Instead you need to check if the settings tab is open, if not open it and so on. I've edited your code in the quote to demonstrate this. Edited March 29, 20187 yr by d0zza
March 29, 20187 yr First line do if(tabs.open(Tabs.INVENTORY)) instead, you don't need to check if its already open since thats already checked in the open method.
March 29, 20187 yr As a note, this code works but I shouldn't be using the widget ids and instead be using the text to prevent the widgets breaking from update to update. private RS2Widget getServantWidget() { RS2Widget callWidget = widgets.get(370, 19); if (callWidget != null) callWidget = callWidget.getChildWidget(0); return callWidget; } private RS2Widget getHouseWidget() { RS2Widget houseWidget = widgets.get(261, 78); return houseWidget; } private boolean callServant() { if (tabs.open(Tab.SETTINGS)) { log("Settings tab open"); RS2Widget widget = getServantWidget(); if (widget != null) { if (widget.interact("Call Servant")) { if (!CTime.sleepUntil(random(1000, 2000), 100, () -> dialogues.inDialogue())) { return talkToButler(); } } } else { widget = getHouseWidget(); if (widget != null) { if (widget.interact("View House Options")) { CTime.sleepUntil(random(1250, 2000), 100, () -> getServantWidget() != null); } } } } return false; } Edited March 29, 20187 yr by withoutidols
Create an account or sign in to comment