gerwinb500 Posted March 23, 2020 Share Posted March 23, 2020 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? Quote Link to comment Share on other sites More sharing options...
Camaro Posted March 23, 2020 Share Posted March 23, 2020 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 Quote Link to comment Share on other sites More sharing options...
gerwinb500 Posted March 23, 2020 Author Share Posted March 23, 2020 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? Quote Link to comment Share on other sites More sharing options...
Chris Posted March 24, 2020 Share Posted March 24, 2020 (edited) 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, 2020 by Chris Quote Link to comment Share on other sites More sharing options...
gerwinb500 Posted March 25, 2020 Author Share Posted March 25, 2020 Already fixed it, thanks for replies tho. I started programming java about a week ago, so I'm still a noob lol Quote Link to comment Share on other sites More sharing options...