Viston Posted July 11, 2017 Share Posted July 11, 2017 (edited) 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 July 11, 2017 by Visty Quote Link to comment Share on other sites More sharing options...
Eliot Posted July 11, 2017 Share Posted July 11, 2017 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(); } 1 Quote Link to comment Share on other sites More sharing options...
Viston Posted July 11, 2017 Author Share Posted July 11, 2017 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 Quote Link to comment Share on other sites More sharing options...
Eliot Posted July 11, 2017 Share Posted July 11, 2017 3 minutes ago, Visty said: Nope 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(); 1 Quote Link to comment Share on other sites More sharing options...
Viston Posted July 11, 2017 Author Share Posted July 11, 2017 (edited) 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? Edited July 11, 2017 by Visty Quote Link to comment Share on other sites More sharing options...
Eliot Posted July 11, 2017 Share Posted July 11, 2017 I'd need to see your onLoop, etc. 1 Quote Link to comment Share on other sites More sharing options...
Viston Posted July 11, 2017 Author Share Posted July 11, 2017 (edited) 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 It's always these small things that fucks with the whole script Edited July 11, 2017 by Visty 1 Quote Link to comment Share on other sites More sharing options...
Chris Posted July 11, 2017 Share Posted July 11, 2017 just use onloop bro. 1 Quote Link to comment Share on other sites More sharing options...
Juggles Posted July 11, 2017 Share Posted July 11, 2017 [0:04:44] Juggles: getWidget.get(id,id).interact("Action"); Quote Link to comment Share on other sites More sharing options...
Viston Posted July 11, 2017 Author Share Posted July 11, 2017 (edited) 3 minutes ago, Juggles said: [0:04:44] Juggles: getWidget.get(id,id).interact("Action"); Ids for widgets nono Edited July 11, 2017 by Visty Quote Link to comment Share on other sites More sharing options...
Juggles Posted July 11, 2017 Share Posted July 11, 2017 3 minutes ago, Visty said: Ids for widgets nono static Quote Link to comment Share on other sites More sharing options...
Viston Posted July 11, 2017 Author Share Posted July 11, 2017 Just now, Juggles said: static But but but... Statics are love men Quote Link to comment Share on other sites More sharing options...
Apaec Posted July 11, 2017 Share Posted July 11, 2017 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 It's always these small things that fucks with the whole script 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 ^^! 3 Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted July 11, 2017 Share Posted July 11, 2017 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 Quote Link to comment Share on other sites More sharing options...
Eliot Posted July 11, 2017 Share Posted July 11, 2017 (edited) 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 July 11, 2017 by Eliot Quote Link to comment Share on other sites More sharing options...