Jump to content

Interaction gives NullPointerException?


Dab in a Lab

Recommended Posts

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

 

Link to comment
Share on other sites

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

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?

Link to comment
Share on other sites

8 minutes ago, Dab in a Lab said:

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?

No. Log is for log check/ error checking. You need to make use of curly braces.

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

4 minutes ago, Charlotte said:

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.

I have conditional sleeps

https://gyazo.com/07f3d1bba0ef6246ae6db8abcb83b917

Edited by Dab in a Lab
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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