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.


Making character can eat wood.

Recommended Posts

orlyx    1

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)

Share this post

Link to post
Share on other sites
Sergio A V    0

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)


    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


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:ListenForEvent("lightningstrike", onlightingstrike)

    local light = inst.entity:AddLight()
    inst.OnLongUpdate = function(inst, dt) 
        inst.charge_time = math.max(0, inst.charge_time - dt)

    inst:DoPeriodicTask(1/10, function() dorainsparks(inst, 1/10) end)
    inst.OnSave = onsave
    inst.OnLoad = onload
    inst.OnPreLoad = onpreload


Share this post

Link to post
Share on other sites
parityb1t    0

In `log.lua` and 'twigs.lua', it shows that wood logs are already edible

inst.components.edible.foodtype = "WOOD"

You can set the following for the `eater` component of your character


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.


Share this post

Link to post
Share on other sites