scriptersteve Posted September 23, 2018 Share Posted September 23, 2018 Problem occurs with turning melee on. if (this.config.containsPrayer("Protect from Melee")) { if (!prayer.isActivated(PrayerButton.PROTECT_FROM_MELEE)) { prayer.set(PrayerButton.PROTECT_FROM_MELEE, true); log("turning on protect from melee"); } } Quote Link to comment Share on other sites More sharing options...
Explv Posted September 23, 2018 Share Posted September 23, 2018 (edited) 1 hour ago, scriptersteve said: Problem occurs with turning melee on. if (this.config.containsPrayer("Protect from Melee")) { if (!prayer.isActivated(PrayerButton.PROTECT_FROM_MELEE)) { prayer.set(PrayerButton.PROTECT_FROM_MELEE, true); log("turning on protect from melee"); } } The API looks for the protect from melee prayer using the sprite ID 129. The warning is raised when either no widget with that sprite ID is found, or more than 1 widget with that sprite ID is found. I don't have 43 prayer, so I cannot determine if this sprite ID is correct. I think the sprite ID is different if the prayer is disabled (for me it's 149). What you should do is debug the widget (541, 18, 1) using the widget debugger in the client (Settings -> Options -> Widget Debugger) and look at the value of Sprite ID 1 (enabled). If you have 43 prayer, and you are able to toggle protect from melee on and off, and the sprite ID is not 129, then you should file a bug report. Either way post here what you find. Edited September 23, 2018 by Explv 1 Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted September 23, 2018 Author Share Posted September 23, 2018 17 minutes ago, Explv said: The API looks for the protect from melee prayer using the sprite ID 129. The warning is raised when either no widget with that sprite ID is found, or more than 1 widget with that sprite ID is found. I don't have 43 prayer, so I cannot determine if this sprite ID is correct. I think the sprite ID is different if the prayer is disabled (for me it's 149). What you should do is debug the widget (541, 18, 1) using the widget debugger in the client (Settings -> Options -> Widget Debugger) and look at the value of Sprite ID 1 (enabled). If you have 43 prayer, and you are able to toggle protect from melee on and off, and the sprite ID is not 129, then you should file a bug report. Either way post here what you find. sprite ID is 129 when enables and -1 when disabled. What exactly are sprite IDs- normally i just use the widget hover thing and try the 3 options till one works Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted September 23, 2018 Author Share Posted September 23, 2018 is still failing to click on protect melee though? Quote Link to comment Share on other sites More sharing options...
Explv Posted September 23, 2018 Share Posted September 23, 2018 (edited) 42 minutes ago, scriptersteve said: sprite ID is 129 when enables and -1 when disabled. What exactly are sprite IDs- normally i just use the widget hover thing and try the 3 options till one works A sprite is: https://en.wikipedia.org/wiki/Sprite_(computer_graphics) In this case the sprite is the little sword icon for the prayer, and the sprite ID uniquely identifies that sprite. Ok so you say the sprite ID is 129, which is correct, there must be another issue here. Here is (roughly) the OSBot Prayer.set function, with some added debug log statements. Try using this function instead of the OSBot version, and tell me what the output in the log is. Maybe we can figure out what's breaking. private static int prayerRootID = -1; public boolean set(PrayerButton prayer, boolean activate) { if (getPrayer().isActivated(prayer) == activate || !getPrayer().hasLevelFor(prayer)) { return false; } if (!getPrayer().open()) { return false; } if (prayerRootID == -1) { Optional<RS2Widget> prayerIconWidget = getWidgets().getAll() .stream() .filter(w -> w.getSpriteIndex1() == Sprites.PRAYER_ICON_INSIDE_TAB) .findFirst(); if (!prayerIconWidget.isPresent()) { return false; } prayerRootID = prayerIconWidget.get().getRootId(); log("Found prayer root ID: " + prayerRootID); } List<RS2Widget> prayerWidgets = getWidgets().containingSprite(prayerRootID, prayer.getSpriteId()); log("Found prayer button widgets: " + Arrays.toString(prayerWidgets.toArray())); if (prayerWidgets.size() == 1) { return prayerWidgets.get(0).interact(activate ? "Activate" : "Deactivate"); } else { warn("A problem was encountered with identifying prayer button for " + prayer.toString()); return false; } } Edited September 23, 2018 by Explv 1 Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted September 23, 2018 Author Share Posted September 23, 2018 (edited) https://gyazo.com/3f5544952cb27733738828a52c8bc095 Seems to miss the widget? Renamed yours to pset and used that and above occured. Prayer code was working ~~ 3-4 weeks ago when I last tried checking/editing it if (this.config.containsPrayer("Protect from Melee")) { if (!prayer.isActivated(PrayerButton.PROTECT_FROM_MELEE)) { pset(PrayerButton.PROTECT_FROM_MELEE, true); log("turning on protect from melee"); } } Edited September 23, 2018 by scriptersteve Quote Link to comment Share on other sites More sharing options...
Explv Posted September 23, 2018 Share Posted September 23, 2018 (edited) 7 minutes ago, scriptersteve said: https://gyazo.com/3f5544952cb27733738828a52c8bc095 Seems to miss the widget? Ok, so that indicates that this block of code, is not working for you: if (prayerRootID == -1) { Optional<RS2Widget> prayerIconWidget = getWidgets().getAll() .stream() .filter(w -> w.getSpriteIndex1() == Sprites.PRAYER_ICON_INSIDE_TAB) .findFirst(); if (!prayerIconWidget.isPresent()) { return false; } prayerRootID = prayerIconWidget.get().getRootId(); log("Found prayer root ID: " + prayerRootID); } That's strange because it works just fine for me: [INFO][Bot #1][09/23 11:35:17 AM]: Found prayer root ID: 541 Are you running mirror mode or injection? Also I missed the following line from my original snippet: private static int prayerRootID = -1 Make sure you have that as a variable if you don't already (refer to my updated snippet in the previous comment) Edited September 23, 2018 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted September 23, 2018 Share Posted September 23, 2018 15 minutes ago, scriptersteve said: https://gyazo.com/3f5544952cb27733738828a52c8bc095 Seems to miss the widget? Renamed yours to pset and used that and above occured. Prayer code was working ~~ 3-4 weeks ago when I last tried checking/editing it if (this.config.containsPrayer("Protect from Melee")) { if (!prayer.isActivated(PrayerButton.PROTECT_FROM_MELEE)) { pset(PrayerButton.PROTECT_FROM_MELEE, true); log("turning on protect from melee"); } } Are you using injection or mirror mode? Also try the following: public boolean set(PrayerButton prayer, boolean activate) { if (getPrayer().isActivated(prayer) == activate || !getPrayer().hasLevelFor(prayer)) { return false; } if (!getPrayer().open()) { return false; } List<RS2Widget> prayerWidgets = getWidgets().containingSprite(541, prayer.getSpriteId()); if (!prayerWidgets.isEmpty() && prayerWidgets.size() <= 1) { return prayerWidgets.get(0).interact(activate ? "Activate" : "Deactivate"); } else { warn("A problem was encountered with identifying prayer button for " + prayer.toString()); return false; } } 1 Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted September 23, 2018 Author Share Posted September 23, 2018 I am using injection and same error message for the 2nd code as well - think i'll just assume it's a client issue as it has always worked fine previously (raised bug report for it yesterday) (it's not overly the end of the world for me (just need to manually turn on prot melee when starting the script) - Thanks for your help and hopefully it'll be fixed soon Quote Link to comment Share on other sites More sharing options...