Jump to content

Making character can eat wood.


orlyx

Recommended Posts

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
Share on other sites

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.

 

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...