March 23, 20205 yr Hi everyone. Currently I'm working on a script that buys items needed. Unfortunatly , I ran in to a problem. When buying the item, I want it to press the +5% button in the buy screen. To do this I need to filter out this button. Since I'm not willing to use ID's, I tried filtering on interact actions. This is the code I used: RS2Widget plusButton = getWidgets().singleFilter(getWidgets().getAll(), w -> w.getInteractActions()[0].equals("+5%")); plusButton.interact(); When I run this code, the OSBot logger returns the following error: [ERROR][Bot #1][03/23 05:07:58 PM]: Error in script executor! java.lang.NullPointerException at PlainPizzaMaker.buyItem(PlainPizzaMaker.java:130) at PlainPizzaMaker.onLoop(PlainPizzaMaker.java:116) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(nj:193) at java.lang.Thread.run(Unknown Source) Any suggestions on how to fix it and why it's not working?
March 23, 20205 yr Theres a couple of null checks that need to happen for that to effectively work. Inside the lambda, w needs to be null checked. Also, w.getInteractActions() can return null if the widget does not have any interact actions, so that needs to be null checked. Finally, plusButton itself can be null. Null check that before interacting with it. You should also check if the array contains the string rather than just checking the first index
March 23, 20205 yr Author I think understand what you mean, but I don't know how to implement the nul check of w and w.getInteractActions(). Could you maybe write a sample code or explain?
March 24, 20205 yr On 3/23/2020 at 2:55 PM, gerwinb500 said: I think understand what you mean, but I don't know how to implement the nul check of w and w.getInteractActions(). Could you maybe write a sample code or explain? learn java pls There are easier methods to use btw https://osbot.org/api/org/osbot/rs07/api/Widgets.html Edited March 24, 20205 yr by Chris
March 25, 20205 yr Author Already fixed it, thanks for replies tho. I started programming java about a week ago, so I'm still a noob lol
Create an account or sign in to comment