orlyx Posted December 16, 2017 Share Posted December 16, 2017 Im very new in moding/scripting and i wanna know how can i make my character will be able to eat wood?(will grain +10 hunger +5 health) Link to comment https://forums.kleientertainment.com/forums/topic/85493-making-character-can-eat-wood/ Share on other sites More sharing options...
Sergio A V Posted December 19, 2017 Share Posted December 19, 2017 I'm not too sure but I think you have to make logs (sticks and boards if you want too) edible items This is code from gears.lua (because wx-78 can eat them) Spoiler inst:AddComponent("edible") inst.components.edible.foodtype = "GEARS" inst.components.edible.healthvalue = TUNING.HEALING_HUGE inst.components.edible.hungervalue = TUNING.CALORIES_HUGE inst.components.edible.sanityvalue = TUNING.SANITY_HUGE There's an example of how to modify a prefab here This is the function (I believe) that allows wx-78 to eat gears Spoiler local fn = function(inst) inst.level = 0 inst.charge_time = 0 inst.spark_time = 3 inst.components.eater.ignoresspoilage = true table.insert(inst.components.eater.foodprefs, "GEARS") inst.components.eater:SetOnEatFn(oneat) applyupgrades(inst) inst:AddComponent("playerlightningtarget") inst:ListenForEvent("lightningstrike", onlightingstrike) local light = inst.entity:AddLight() inst.Light:Enable(false) inst.Light:SetRadius(2) inst.Light:SetFalloff(0.75) inst.Light:SetIntensity(.9) inst.Light:SetColour(235/255,121/255,12/255) inst.OnLongUpdate = function(inst, dt) inst.charge_time = math.max(0, inst.charge_time - dt) end inst:DoPeriodicTask(1/10, function() dorainsparks(inst, 1/10) end) inst.OnSave = onsave inst.OnLoad = onload inst.OnPreLoad = onpreload end Link to comment https://forums.kleientertainment.com/forums/topic/85493-making-character-can-eat-wood/#findComment-985466 Share on other sites More sharing options...
parityb1t Posted January 5, 2018 Share Posted January 5, 2018 (edited) In `log.lua` and 'twigs.lua', it shows that wood logs are already edible inst:AddComponent("edible") inst.components.edible.foodtype = "WOOD" You can set the following for the `eater` component of your character inst.components.eater:SetBeaver() That will set in the eater component `self.foodprefs` to "WOOD". Which allows the character to eat wood (but I think wood only?). You can play around with eater.foodprefs to get the combination you desire for what character can eat. Edited January 5, 2018 by parityb1t Link to comment https://forums.kleientertainment.com/forums/topic/85493-making-character-can-eat-wood/#findComment-990060 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