Jump to content

Why is my conditional sleep activating before task complete?


Jar

Recommended Posts

My conditional sleep is executing, before it's completed the set task above it, I'm not sure why though?

 

Example of code  ( This was my first attempt ) - ( but it kept running the conditional sleep, before even clicking inventory tab )

            getTabs().open(Tab.INVENTORY);

            new ConditionalSleep(15000, 600) {
                @Override
                public boolean condition() {
                    log("Wait for Fishing tut!");
                    RS2Widget FishingWidg = getWidgets().getWidgetContainingText(263, "Fishing");
                    return FishingWidg != null && FishingWidg.isVisible();
                }
            }.sleep();

This was my second attempt -

        getTabs().open(Tab.INVENTORY);

        if(getTabs().isOpen(Tab.INVENTORY)) {

            new ConditionalSleep(15000, 600) {
                @Override
                public boolean condition() {
                    log("Wait for Fishing tut!");
                    RS2Widget FishingWidg = getWidgets().getWidgetContainingText(263, "Fishing");
                    return FishingWidg != null && FishingWidg.isVisible();
                }
            }.sleep();

        }

But still the same issue...?

It's strange though because sometimes it works correctly & sometimes it doesn't..

Link to comment
Share on other sites

23 minutes ago, Jar said:

 


        getTabs().open(Tab.INVENTORY);

        if(getTabs().isOpen(Tab.INVENTORY)) {

            new ConditionalSleep(15000, 600) {
                @Override
                public boolean condition() {
                    log("Wait for Fishing tut!");
                    RS2Widget FishingWidg = getWidgets().getWidgetContainingText(263, "Fishing");
                    return FishingWidg != null && FishingWidg.isVisible();
                }
            }.sleep();

        }

But still the same issue...?

 

What do you mean by still the same issue? Does the ConditionalSleep never get executed in this case?

If the inventory tab is already open, the bot won't click on the inventory tab.

Link to comment
Share on other sites

1 minute ago, Juggles said:

Why are you using widgets when you can sleep until getTabs.getOpen==Tabs.Inventory?

 


He shouldn't be using either. getTabs().open(Tab) will sleep until the tab is open anyway.

+ He should be using configs like here: https://github.com/Explv/Tutorial-Island/blob/master/src/sections/SurvivalSection.java#L35

Edited by Explv
Link to comment
Share on other sites

3 minutes ago, Juggles said:

Why are you using widgets when you can sleep until getTabs.getOpen==Tabs.Inventory?

 

The conditional sleep isn't waiting for the inventory tab to be open... it's waiting for the next stage of the tutorial which in this case is " Fishing " which appears in chatbox after clicking inventory tab

Link to comment
Share on other sites

44 minutes ago, Jar said:

The conditional sleep isn't waiting for the inventory tab to be open... it's waiting for the next stage of the tutorial which in this case is " Fishing " which appears in chatbox after clicking inventory tab

Sorry I'm on my phone. 

If you're doing tut island then use Configs

Link to comment
Share on other sites

9 minutes ago, Juggles said:

Sorry I'm on my phone. 

If you're doing tut island then use Configs

No problem, I managed to fix it by adding a if statement -

 

if(!getTabs().isOpen(Tab.INVENTORY)) { }

which made it work, but I still don't see why that is necessary, i should be able to just call " getTabs().open(Tab.INVENTORY); " but never mind it works now i guess..

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...