Tasemu Posted May 23, 2017 Share Posted May 23, 2017 I've noticed when running OSBot in debug mode I am getting a lot of null pointer errors because my bot is not logged in yet and the world has not loaded. Is there a best practise method for holding the script until the world is correctly loaded in? Cheers! Quote Link to comment Share on other sites More sharing options...
Hel Posted May 23, 2017 Share Posted May 23, 2017 if(getClient().isLoggedIn()) Quote Link to comment Share on other sites More sharing options...
Shudsy Posted May 23, 2017 Share Posted May 23, 2017 (edited) 9 minutes ago, Slut said: if(getClient().isLoggedIn()) This returns true during the "Loading please wait" message aswell, and items will still return null. Edited May 23, 2017 by Shudsy Quote Link to comment Share on other sites More sharing options...
Hel Posted May 23, 2017 Share Posted May 23, 2017 6 minutes ago, Shudsy said: This returns true during the "Loading please wait" message aswell, and items will still return null. I've never had an issue with this and I use it alongside ingame widgets that are only visible once things are loaded, but noted Quote Link to comment Share on other sites More sharing options...
Tasemu Posted May 23, 2017 Author Share Posted May 23, 2017 Any checks for world loaded? Maybe checking if the character is visible...? lol Quote Link to comment Share on other sites More sharing options...
Polymorphism Posted May 23, 2017 Share Posted May 23, 2017 widgets -> singleFilter -> parent 548 ->hasAction Look North Sorry in a rush can't write the code, check if that widget is visbile Quote Link to comment Share on other sites More sharing options...
Hayase Posted May 24, 2017 Share Posted May 24, 2017 I like to use player indexes on first startup if (getClient().getMyPlayerIndex() > 0) { //or whatever //..... } Quote Link to comment Share on other sites More sharing options...
Tasemu Posted May 24, 2017 Author Share Posted May 24, 2017 On 2017-5-23 at 10:06 AM, Shudsy said: This returns true during the "Loading please wait" message aswell, and items will still return null. public boolean isLoggedIn() Returns if you are currently logged in. Returns: True if logged in and not logged out or 'loading please wait...'. Is the api docs out of date? or is the description wrong? Quote Link to comment Share on other sites More sharing options...
Shudsy Posted May 24, 2017 Share Posted May 24, 2017 8 minutes ago, Tasemu said: public boolean isLoggedIn() Returns if you are currently logged in. Returns: True if logged in and not logged out or 'loading please wait...'. Is the api docs out of date? or is the description wrong? Not sure, but isLoggedIn() always bugs out for me when checking for items Quote Link to comment Share on other sites More sharing options...
Juggles Posted May 24, 2017 Share Posted May 24, 2017 Check for item in inventory Quote Link to comment Share on other sites More sharing options...
Tom Posted May 24, 2017 Share Posted May 24, 2017 Couldn't you just check if the player is visible? Quote Link to comment Share on other sites More sharing options...