Jump to content

Interaction gives NullPointerException?


Recommended Posts

Posted

Why is my log giving this error? I made some changes, so it only has like a ~2 second delay to continue its action now, but its still kinda annoying. I saw that it provided more info about true or false and null methods, but I don't quite understand how that's relevant

Logger:

https://gyazo.com/bfd0d678cf7449a15894023b594844d3

Snippet of script:

https://gyazo.com/d16de96eb83d637888a0fc5e6e8cebfc

 

Posted
23 minutes ago, Dab in a Lab said:

Why is my log giving this error? I made some changes, so it only has like a ~2 second delay to continue its action now, but its still kinda annoying. I saw that it provided more info about true or false and null methods, but I don't quite understand how that's relevant

Logger:

https://gyazo.com/bfd0d678cf7449a15894023b594844d3

Snippet of script:

https://gyazo.com/d16de96eb83d637888a0fc5e6e8cebfc

 

X7uYWwD.png

*Correction fixed

brackets apply to  both if statements

25 minutes ago, Dab in a Lab said:

Why is my log giving this error? I made some changes, so it only has like a ~2 second delay to continue its action now, but its still kinda annoying. I saw that it provided more info about true or false and null methods, but I don't quite understand how that's relevant

Logger:

https://gyazo.com/bfd0d678cf7449a15894023b594844d3

Snippet of script:

https://gyazo.com/d16de96eb83d637888a0fc5e6e8cebfc

 

if (condition)
   statement1;
   statement2; 
//statement2 is not part of the if statement, but it looks like it because of wrong indentation
  • Like 1
Posted
6 minutes ago, Chris said:

X7uYWwD.png

*Correction fixed

brackets apply to  both if statements


if (condition)
   statement1;
   statement2; 
//statement2 is not part of the if statement, but it looks like it because of wrong indentation

Thank you! I kinda just assumed the null check would skip any log statements. If I were to get rid of the log under the null check, that would have fixed the issue too right?

Posted
4 minutes ago, Dab in a Lab said:

@Chris I added the brackets but the script seems to skip over that snippet and run through the rest of the code. Then loops back and performs the action. Could that be because of how the rest of my script is written?

First you need to understand that the code runs continuously and sometimes it skips certain parts, hence this where I will make use of conditional sleep.

Posted
3 minutes ago, Charlotte said:

Don't see it for interaction, which is what you said was skipped. Curly braces still not used.

I added brackets to where Chris said, but the interaction is still a NullPointException. The place the brackets seemed to work was where I had them in the previous picture

https://gyazo.com/e41c968d49aafb68f7ee3d4694e07f04

And I have the conditional sleep return if the widget I'm interacting with exists. Should I instead have it return the interaction?

Posted
2 minutes ago, Dab in a Lab said:

I added brackets to where Chris said, but the interaction is still a NullPointException. The place the brackets seemed to work was where I had them in the previous picture

https://gyazo.com/e41c968d49aafb68f7ee3d4694e07f04

And I have the conditional sleep return if the widget I'm interacting with exists. Should I instead have it return the interaction?

Wrong use of curly braces.

if (T_AREA.contains(myPlayer())) {
	NPC t = getNpcs().closest("Ellis");
	if (t != null) {
		t.interact("Trade");
	}
}

 

  • Like 2

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