Santas Posted October 1, 2014 Share Posted October 1, 2014 How do you pick up grounditems? I did this int feather = 314; GroundItem Feathers = groundItems.closest(feather); if(Feathers != null) Feathers.interact("Take"); Doesn't seem to work, what is the right way to do it? Link to comment Share on other sites More sharing options...
BurritoBug Posted October 1, 2014 Share Posted October 1, 2014 (edited) int feather = 314; This part seems like a waste of time GroundItem Feathers = groundItems.closest(314); if(Feathers != null){ Feathers.interact("Take"); } you need these {} after an if statement Edited October 1, 2014 by Sentende Link to comment Share on other sites More sharing options...
Swizzbeat Posted October 2, 2014 Share Posted October 2, 2014 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 More sharing options...
BurritoBug Posted October 2, 2014 Share Posted October 2, 2014 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. the id's change like once every hundred million years i guess it is good practice though :P Link to comment Share on other sites More sharing options...
Santas Posted October 2, 2014 Author Share Posted October 2, 2014 (edited) It spits out an exception in my face Link to image : http://i.imgur.com/P2kDmOl.png (incase it does not load for you) Edited October 2, 2014 by Santas Link to comment Share on other sites More sharing options...
BurritoBug Posted October 2, 2014 Share Posted October 2, 2014 It spits out an exception in my face Link to image : http://i.imgur.com/P2kDmOl.png (incase it does not load for you) Pastebin your code Link to comment Share on other sites More sharing options...
Santas Posted October 2, 2014 Author Share Posted October 2, 2014 (edited) Pastebin your code http://pastebin.com/05ppNaAc Edit : I forgot to mention I changed the id to iron ore where I was standing so I can test the script Edited October 2, 2014 by Santas Link to comment Share on other sites More sharing options...
BurritoBug Posted October 2, 2014 Share Posted October 2, 2014 (edited) http://prntscr.com/4s8hq7 i think you show make a void for pickup and wait and call them in your cases Edited October 2, 2014 by Sentende Link to comment Share on other sites More sharing options...
Santas Posted October 2, 2014 Author Share Posted October 2, 2014 http://prntscr.com/4s8hq7 i think you show make a void for pickup and wait and call them in your cases Thanks, a lot that works. May I also ask why does it work this way and not the other way around? Link to comment Share on other sites More sharing options...
Joseph Posted October 2, 2014 Share Posted October 2, 2014 (edited) Thanks, a lot that works. 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 October 2, 2014 by josedpay 2 Link to comment Share on other sites More sharing options...