jjdamstra Posted February 17, 2015 Share Posted February 17, 2015 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 Link to comment Share on other sites More sharing options...
bigpak Posted February 17, 2015 Share Posted February 17, 2015 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 Link to comment 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 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 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 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 Share on other sites More sharing options...
Sketchiverse Posted February 19, 2015 Share Posted February 19, 2015 Didn't see you made a second topic... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.