Jump to content

Trouble with Widgets


Viston

Recommended Posts

I've been having some trouble with widgets lately, can't seem to make it detect whether a widget is visible or not properly.

So I currently have this Task assigned. It can't seem to be able to validate when the widget appears. I noticed it detects the widget right when I stop the script, and if I restart the script without refreshing the script selection window, it detects the widget, but not able to execute the method.

Code:

/**
 * Created by Viston on 11/07/2017.
 */
public class InsideDreamWalkToMid extends Task {
    public InsideDreamWalkToMid(MethodProvider s) {
        super(s);
    }

    @Override
    public boolean canProcess() {
        RS2Widget inDreamWidget;
        inDreamWidget = s.getWidgets().singleFilter(s.getWidgets().getAll(), widget -> widget != null && widget.getMessage().contains("Points:"));
        return inDreamWidget != null && inDreamWidget.isVisible();
    }

    @Override
    public void process() throws InterruptedException {
        Paint.status = "Inside...";
        Vars.middleTile = s.myPosition().translate(10, 15);
        s.getWalking().walk(Vars.middleTile))
    }
}

--------------------------------------------------------------------------------------------------------------------------------------------------------------

A gif of my explanation above > http://i.imgur.com/NXu1zM2.gifv

As you can see, if I refresh before starting the script, it's not able to detect the widget. However, just when I stop the script, the Paint.status = "Inside..."; appears, which means it successfully validated the task.

If I start the script without refreshing, it's able to detect the widget, yet not able to execute the method.

Edited by Visty
Link to comment
Share on other sites

Maybe I'm confused but doesn't singleFilter take the root id and filters? Why are you passing singleFilter widgets?

 

Does this work?

    @Override
    public boolean canProcess() {
        RS2Widget inDreamWidget = s.getWidgets().getWidgetContainingText("Points:");
        return inDreamWidget != null && inDreamWidget.isVisible();
    }
  • Like 1
Link to comment
Share on other sites

2 minutes ago, Eliot said:

Maybe I'm confused but doesn't singleFilter take the root id and filters? Why are you passing singleFilter widgets?

 

Does this work?


    @Override
    public boolean canProcess() {
        RS2Widget inDreamWidget = s.getWidgets().getWidgetContainingText("Points:");
        return inDreamWidget != null && inDreamWidget.isVisible();
    }

Nope :feels:

Link to comment
Share on other sites

5 minutes ago, Eliot said:

That's odd, not at my PC right now so can't look for myself. Have you used widget debugger at all? Does it work if you remove the 


&& inDreamWidget.isVisible();

Same problem. However, when I removed inDreamWidget.isVisible(); It doesn't Paint the status right when stopping the script.

So the script I had above should be working, why else would it be able to validate the Task right when I stop the script? Isn't that weird? :feels:

Edited by Visty
Link to comment
Share on other sites

12 minutes ago, Eliot said:

I'd need to see your onLoop, etc.

Lmao, fixed it. One of my other Tasks were fucking with it apparently lol.

I had a task that walks to the nmz area in case i'm not there. It was getting validated, which I've fixed now.

Thank you for your effort, it's appreciated! You always there helping out :boge:

It's always these small things that fucks with the whole script :feels: 

Edited by Visty
  • Like 1
Link to comment
Share on other sites

2 hours ago, Visty said:

Lmao, fixed it. One of my other Tasks were fucking with it apparently lol.

I had a task that walks to the nmz area in case i'm not there. It was getting validated, which I've fixed now.

Thank you for your effort, it's appreciated! You always there helping out :boge:

It's always these small things that fucks with the whole script :feels: 

If you're finding bits of your code are interfering with other parts and it's taking you such a long time to debug, perhaps consider the structure of your code? I don't know what your task class does which you're extending with this code, but if it's just some abstract class with those methods that you're overriding, then that seems pretty useless -why not just have your code in your onLoop where you can see it all at once ^^! 

  • Like 3
Link to comment
Share on other sites

2 hours ago, Apaec said:

If you're finding bits of your code are interfering with other parts and it's taking you such a long time to debug, perhaps consider the structure of your code? I don't know what your task class does which you're extending with this code, but if it's just some abstract class with those methods that you're overriding, then that seems pretty useless -why not just have your code in your onLoop where you can see it all at once ^^! 

Don't you then end up with scripts like the 3k lines tut that existed somewhere on here :feels: 

Link to comment
Share on other sites

4 hours ago, Apaec said:

If you're finding bits of your code are interfering with other parts and it's taking you such a long time to debug, perhaps consider the structure of your code? I don't know what your task class does which you're extending with this code, but if it's just some abstract class with those methods that you're overriding, then that seems pretty useless -why not just have your code in your onLoop where you can see it all at once ^^! 

Please don't encourage this (especially for non-trivial scripts). Having a gigantic onLoop would not make this easier to debug, but quite the contrary. The problem in this case is debugging skills and without them, regardless of structure, you will run into these problems.

Edited by Eliot
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...