Jump to content

Carrot Drop


jjdamstra

Recommended Posts

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

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 :D

Link to comment
Share on other sites

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.

×
  • Create New...