Jump to content

Issue with getting myPosition()


Recommended Posts

Posted

Hello all!

I'm writing a basic fishing script. When I set it up the first time it was working decently. Now I'm trying to map it over to a behavior tree (Task based script).

I have this issue where in a Task that checks if the player is at a spot, the myPosition() method keeps giving me a NullPointerException. It says the issue is at org.osbot.rs07.script.MethodProvider.myPlayer(xe:677) and (xe:679).

I've narrowed it down here. The MethodProvider is not null, the getInventory is not null, which means that other methods on the MethodProvider work. The only thing that's returning as null is the myPosition method.

Does anyone have any advice?

Posted
2 hours ago, ExtraBotz said:

How do you know that the MethodProvider is not null?

log(myPosition());

I'd recommend trying the code above in your onStart method. If this works, your method provider may not be instantiated correctly. You need to use the main class as the method provider.

Hey thanks a lot for the suggestion. I determined the MethodProvider wasn't null by having it log something if it != null. The mistake I made was not using the main class as the provider and instead instantiating a new MethodProvider entirely. Your suggestion helped me debug the issue, and now I have my first properly implemented behavior tree! Thanks

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...