Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Need help with widget interact action filer

Featured Replies

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?

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

  • 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? 

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 by Chris

  • 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

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.