Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Conditional sleeps while working with menues

Featured Replies

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;
    }

 

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 by d0zza

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.

 

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 by withoutidols

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.