Jump to content

NullPointer on condition sleep


HunterRS

Recommended Posts

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

6 hours ago, sudoinit6 said:

if(getInventory().interact("Cast", "Maple longbow")){

 

I may not know what I am talking about but this looks odd to me. Is interact a boolean? How do you "if" an interact? Or does that me if I am currently interacting with cast and the target is maple longbow?

 

 

http://prntscr.com/goke1u

Link to comment
Share on other sites

4 hours ago, Alek said:

Is it spamming null pointer a lot? If so you have to stop the script instantly and scroll all the way up to the original stack trace, which is what I suspect is happening.

Nope, I know what you mean and it isn't doing that....

Gives the error once every couple of seconds

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