Jump to content

How to pick up Grounditems?


Santas

Recommended Posts

 

int feather = 314;

This part seems like a waste of time

 

Not at all, enjoy changing all occurrences of "314" if the ID ever changes. Not only that but it's terrible practice.

 

OP: Check whether your interact statement is being called or not.

GroundItem Feathers = groundItems.closest(314);
if(Feathers != null){
Feathers.interact("Take");
}

you need these {} after an if statement

 

No, but thank you for posting something logical.

Link to comment
Share on other sites

Thanks, a lot that works. smile.png

 

May I also ask why does it work this way and not the other way around?

when you created the private field feathers

        GroundItem Feathers = groundItems.closest(feather);

the private field was never initialized. It would of been better if you created a local variable and use it.

case PICK_UP:
	GroundItem Feathers = groundItems.closest(feather);
							
	if(Feathers != null)	{
		Feathers.interact("Take");
                wait(100,250);
	}
	break;

since your private field feathers wasn't initialized it was null what why it gave you a NPE

Edited by josedpay
  • Like 2
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...