Jump to content

Issue with getting myPosition()


Clayplug

Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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