January 15, 20215 yr 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 January 15, 20215 yr by skillerkidos1
January 15, 20215 yr @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());
January 15, 20215 yr 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!
January 15, 20215 yr 9 hours ago, skillerkidos1 said: I think I tried that but now im thinking I used it wrong Will try it now and see if that will work! Always null check this kind of stuff before checking anything ^^
Create an account or sign in to comment