shanharlmal Posted September 24, 2015 Share Posted September 24, 2015 ------------------------------------------------------------------------------------------------------local function oneat(inst, food) --poop fun stuff if food.name == "nitre" then SpawnPrefab("gunpowder").Transform:SetPosition(inst:GetPosition():Get()) end end ------------------------------------------------------------------------------------------------------- I would like only to have my character poop certain things when he eats a certain thing, not a whole foodtype.Honestly can't even test what is wrong because nothing happens. Not sure what is used for the eat event trigger. Also tried to make nitre its own foodtype and use the pigman.lua VEGGIES poop code but nothing. I am putting this in my prefab.lua not main. yes? Link to comment Share on other sites More sharing options...
Mobbstar Posted September 24, 2015 Share Posted September 24, 2015 lol, you need not create a new foodtype. 1. In the main function of your prefab (usually called "fn"), you want to make sure there's:inst.components.eater.oneatfn = oneat 2. It's food.prefab, not food.name Link to comment Share on other sites More sharing options...
shanharlmal Posted September 24, 2015 Author Share Posted September 24, 2015 lol, you need not create a new foodtype. 1. In the main function of your prefab (usually called "fn"), you want to make sure there's:inst.components.eater.oneatfn = oneat 2. It's food.prefab, not food.name Well it crashes now so thats neat. Least something is happening... I added the inst.components.eater.oneatfn = oneat within the local fn in main. Before my oneat function. Link to comment Share on other sites More sharing options...
Mobbstar Posted September 25, 2015 Share Posted September 25, 2015 Well it crashes now so thats neat. Least something is happening... I added the inst.components.eater.oneatfn = oneat within the local fn in main. Before my oneat function. You mean something like the following?inst.components.eater.oneatfn = oneat local function oneat(inst, food) --poop fun stuff Because that is the wrong way around. Lua reads top-to-bottom, and things need to be made before they're assigned. It is correct like the following: local function oneat(inst, food) --poop fun stuff--[...]endinst.components.eater.oneatfn = oneat 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.