jjdamstra Posted February 17, 2015 Share Posted February 17, 2015 (edited) Hi, I'm trying to add a random chance to get an extra carrot when picked this is what I'm using local function AddNewCarrotDrop(inst) local ranNum = math.random(2) inst.components.pickable:SetUp("carrot", 10, ranNum)end AddPrefabPostInit("carrot", AddNewCarrotDrop) It keeps crashing attempt to index field 'pickable' (a nil value) modmain.lua (3,1) this is the same thing I'm using for grass and twigs and they work just fine. Any help would be appreciated Edited February 17, 2015 by jjdamstra Link to comment https://forums.kleientertainment.com/forums/topic/51107-carrot-drop/ Share on other sites More sharing options...
bigpak Posted February 17, 2015 Share Posted February 17, 2015 (edited) I'll attempt to take a look, however I'm not very good at coding. I might have fixed it, let me test.local function AddNewCarrotDrop(inst) local ranNum = math.random(2) inst.components.pickable:SetUp("carrot", 10, ranNum)endAddPrefabPostInit("carrot_planted", AddNewCarrotDrop)There is the fixed code, the issue is if you look in carrot.lua it returns the prefab as carrot_planted. Enjoy! I am actually glad I could help Edited February 17, 2015 by bigpak Link to comment https://forums.kleientertainment.com/forums/topic/51107-carrot-drop/#findComment-614081 Share on other sites More sharing options...
jjdamstra Posted February 17, 2015 Author Share Posted February 17, 2015 Thanks for the quick response but that did not do the trick. I don't get that error and I only get the one carrot so I change the ranNum to be just 100 for testing and I still just get 1 Link to comment https://forums.kleientertainment.com/forums/topic/51107-carrot-drop/#findComment-614092 Share on other sites More sharing options...
bigpak Posted February 17, 2015 Share Posted February 17, 2015 When I did it I had no issues and it worked. Make sure you have the same code as listed above. Link to comment https://forums.kleientertainment.com/forums/topic/51107-carrot-drop/#findComment-614094 Share on other sites More sharing options...
jjdamstra Posted February 17, 2015 Author Share Posted February 17, 2015 Thanks I got it working. i left some thing in the code yours did work thanks for the help Link to comment https://forums.kleientertainment.com/forums/topic/51107-carrot-drop/#findComment-614096 Share on other sites More sharing options...
bigpak Posted February 17, 2015 Share Posted February 17, 2015 No problem, glad I could help. Link to comment https://forums.kleientertainment.com/forums/topic/51107-carrot-drop/#findComment-614099 Share on other sites More sharing options...
Sketchiverse Posted February 19, 2015 Share Posted February 19, 2015 (edited) Didn't see you made a second topic... Edited February 19, 2015 by Sketchiverse Link to comment https://forums.kleientertainment.com/forums/topic/51107-carrot-drop/#findComment-614692 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now