SenL Posted January 31, 2015 Share Posted January 31, 2015 Hi, I want my char to be able to eat petals (yes I know it's already edible) but not any other veggies. So I setGLOBAL.FOODTYPE.MYCHARSFOOD = "MYCHARSFOOD"local mychar_food = {"twigs", "log", "boards", "petal", "petal_evil", "pinecone", "cutgrass", "foliage", "cutlichen"}local function AddMyCharFood(inst) inst:AddTag("edible_"..GLOBAL.FOODTYPE.MYCHARSFOOD)endfor k,v in pairs(mychar_food) do AddPrefabPostInit(v, AddMyCharFood)end(inside modmain.lua) and inst.components.eater.foodprefs = { FOODTYPE.MYCHARSFOOD } local oldEater = inst.components.eater.Eatinst.components.eater.Eat = function(self, food) if self:CanEat(food) then if food.prefab == "twigs" then food.components.edible.healthvalue = 2 food.components.edible.hungervalue = 0 food.components.edible.sanityvalue = 0 elseif food.prefab == "petals" then food.components.edible.healthvalue = 2 food.components.edible.hungervalue = 2 food.components.edible.sanityvalue = 1--other elseif here end end return oldEater(self, food)end(inside mychar.lua, inside master_postinit) So my char is able to eat twigs but not petals because petals foodtype is still VEGGIES.I don't want to change petals foodtype though.I don't want mychar to be able to eat any other VEGGIES either. I read belowhttp://forums.kleientertainment.com/topic/48308-how-do-i-make-my-character-able-to-eat-grass/?hl=edible#entry596414but that's slightly different scenario/case. Any help or hint? Thanks. Link to comment Share on other sites More sharing options...
rezecib Posted January 31, 2015 Share Posted January 31, 2015 @SenL, I don't think the veggies foodtype is the problem. "petal" and "petal_evil" aren't prefabs that exist-- you're looking for "petals", and "petals_evil". Link to comment Share on other sites More sharing options...
SenL Posted January 31, 2015 Author Share Posted January 31, 2015 Oh I'm a dummy. So, how does adding a tag of "edible_MYCHARFOOD" work (making it edible)? Thanks for your continued patience lol. Link to comment Share on other sites More sharing options...
Maris Posted February 1, 2015 Share Posted February 1, 2015 inst.components.edible.foodtype = "MYCHARFOOD" --for petalsandinst.components.eater.foodprefs = { "MYCHARFOOD" } --for character Also look at "edible" and "eater" components. It is in edible.lua and eater.lua files. Link to comment 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