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.

help getting object x - myPosition x

Featured Replies

So I'm trying to get the X of an object in a instance and get my X while in that instance and then subtract them

@Override
public int onLoop() throws InterruptedException {
    RS2Object obj = getObjects().closest(123);



    int distance = myPosition().getX() - obj.getPosition().getX();
I also tried
    int distance = myPosition().getX() - obj.getX();
if(distance <= 2){

//do this

}

 

When I do either of those and start the script I get this error

[ERROR][Bot #1][01/14 07:34:39 PM]: Error in script executor!
java.lang.NullPointerException
    at main.onLoop(main.java:125)
    at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(tk:46)
    at java.lang.Thread.run(Thread.java:748)

 

I'm not really sure what I'm doing wrong any help would be great

Thank you :)

Edited by skillerkidos1

  • Author
12 minutes ago, Gunman said:

@skillerkidos1 Pretty sure it's because something is null and you're not null checking anything. But disregarding that, does the distance api not work for what you're trying to do?


int distance = getMap().distance(obj.getPosition());


 

I think I tried that but now im thinking I used it wrong

Will try it now and see if that will work! :D

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.