Jump to content

NullPointer on condition sleep


Recommended Posts

Posted

so I have this code:

		case ALCH:
			if(getMagic().canCast(NormalSpells.HIGH_LEVEL_ALCHEMY)){
				if(!myPlayer().isAnimating()){
					if(getMagic().castSpell(NormalSpells.HIGH_LEVEL_ALCHEMY)){
						status = "Alching";
						if(getInventory().interact("Cast", "Maple longbow")){
							new ConditionalSleep(3000) {
								@Override
								public boolean condition() {
									return myPlayer().isAnimating();
								}
							}.sleep();
						}
					}
				}
			}
			break;

 

?and I am geting a freaking NPE on declarin the ConditionalSleep, any idea why

Posted
18 minutes ago, Quotations said:

why not just do

 

sleep(random(2800, 3200));

 

or something?

why not just do

 

sleep(random(2800, 3200));

 

or something?

because thats unreliable.

@HunterRS you can use Explv's sleep class here: https://hastebin.com/izebukinep.java (drop it under your main class) and use 

Sleep.sleepUntil(() -> !myPlayer().isAnimating(), 3000);

as an alternative to using ConditionalSleep, it makes the code more readable imo

 

Posted
51 minutes ago, Quotations said:

why not just do

 

sleep(random(2800, 3200));

 

or something?

why not just do

 

sleep(random(2800, 3200));

 

or something?

Please don't troll here, we have a SPAM section for troll posts.

 

28 minutes ago, 3qTQlBnsOsyfetvA said:

because thats unreliable.

@HunterRS you can use Explv's sleep class here: https://hastebin.com/izebukinep.java (drop it under your main class) and use 


Sleep.sleepUntil(() -> !myPlayer().isAnimating(), 3000);

as an alternative to using ConditionalSleep, it makes the code more readable imo

 

Not sure how that solves his problem. Conditional sleeping is working on other scripts, so it must be something wrong. 

 

@HunterRS Post the stack trace/error

Posted (edited)
46 minutes ago, Alek said:

Please don't troll here, we have a SPAM section for troll posts.

 

Not sure how that solves his problem. Conditional sleeping is working on other scripts, so it must be something wrong. 

 

@HunterRS Post the stack trace/error

Error in script executor!
java.lang.NullPointerException
    at Main.onLoop(Main.java:385)
    at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(xe:49)
    at java.lang.Thread.run(Unknown Source).

 

 

EDIT: it is no longer in the condition sleep
Line 385:

if(getMagic().castSpell(NormalSpells.HIGH_LEVEL_ALCHEMY)){

 

Edited by HunterRS

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