Jump to content

NullPointer in api.map.area.contains when starting script in CLI mode with norandoms?


Recommended Posts

Posted

I'm starting my script in CLI with 

-allow norandoms

and when onStart is called, my script first tries to get a good starting state by checking if we're currently in a bank with: 

Banks.GRAND_EXCHANGE.contains(script.myPlayer())

 

This is immediately causing a NullPointer Exception at "org.osbot.rs07.api.map.area.contains(jk:91)"

 

I originally thought perhaps OSBot hadn't fully initialized by the time onStart was called, so I added a 20 second sleep just to debug the problem.  However, this did nothing and the crash still occurred 20 seconds later.  

Is this a bug, or am I doing something wrong?

Posted (edited)
1 hour ago, RuneMaker4657 said:

I allways use 


AREA.contains(myPlayer())

never saw script.myplayer

Try contains(myPlayer()) only

If you can simply call myPlayer, then you're in a class that inherits myPlayer (you probably extend bot or script).  I have custom classes that do not inherit from OSBot classes, so I have to actually pass script around.

 

1 hour ago, Alek said:

Why are you using script and not bot? 

Is there a reason I should use Bot over Script?  My main class extends script and passes itself to my "Activity" classes which actually contain the logic for doing things.  I got this style from guides like Apaec's Beginner Guide.  I saw that Explev used a different method of having his Activity classes inherit from MethodProvider, and then called exchangeContext(getBot) on each of them: https://github.com/Explv/Tutorial-Island/blob/master/src/script/TutorialIsland.java#L22; but exchangeContext is deprecated by the looks of it.

 

What would you recommend?

1 hour ago, FrostBug said:

Guessing you aren't logged in when it occurs, hence 'myPlayer' being null?

Try checking loginstate

That's probably the case.  I'm not sure why norandom is starting my script before my player is logged in; but maybe that boils down to me not understanding fully what norandom does.

 

I'll make sure to not initialize without checking loginstate first.  Thanks!

Edited by Colonel_Panic
Posted
1 hour ago, Colonel_Panic said:

That's probably the case.  I'm not sure why norandom is starting my script before my player is logged in; but maybe that boils down to me not understanding fully what norandom does.

I'll make sure to not initialize without checking loginstate first.  Thanks!

because norandoms disabled random solvers.

Autologin is a random solver

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...