Jump to content

Food Item Not Increasing Sanity


Recommended Posts

I've made some custom food items in the crock pot, and they work find in DS vanilla.

 

But in DS together they don't seem to be affecting sanity.

 

The Prefab Item.lua

local Assets =
{
Asset("ANIM", "anim/fish_n_chips.zip"),
Asset("ATLAS", "images/inventoryimages/fish_n_chips.xml"),
}

local prefabs =
{
"spoiled_food",
}

local function fn(Sim)
local inst = CreateEntity()
inst.entity:AddTransform()
inst.entity:AddAnimState()
if TheSim:GetGameID() =="DST" then inst.entity:AddNetwork() end

MakeInventoryPhysics(inst)
MakeSmallBurnable(inst)
MakeSmallPropagator(inst)

inst.AnimState:SetBank("fish_n_chips")
inst.AnimState:SetBuild("fish_n_chips")
inst.AnimState:PlayAnimation("idle", false)

inst:AddTag("preparedfood")
inst:AddTag("catfood")

if TheSim:GetGameID()=="DST" then
if not TheWorld.ismastersim then
return inst
end

inst.entity:SetPristine()
end

inst:AddComponent("edible")
inst.components.edible.foodtype = "MEAT"
inst.components.edible.healthvalue = TUNING.HEALING_MED
inst.components.edible.hungervalue = TUNING.CALORIES_MED*2
inst.components.edible.sanityvalue = TUNING.SANITY_TINY,

inst:AddComponent("inspectable")

inst:AddComponent("inventoryitem")
inst.components.inventoryitem.atlasname = "images/inventoryimages/fish_n_chips.xml"

inst:AddComponent("stackable")
inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM

inst:AddComponent("perishable")
inst.components.perishable:SetPerishTime(TUNING.PERISH_FAST)
inst.components.perishable:StartPerishing()
inst.components.perishable.onperishreplacement = "spoiled_food"

inst:AddComponent("bait")

inst:AddComponent("tradable")
inst.components.tradable.goldvalue = 1

return inst
end

return Prefab( "common/inventory/fish_n_chips", fn, Assets )

 

---

 

the modmain.lua contains the following.

local fish_n_chips_recipe = {
        name = "fish_n_chips",
        test = function(cooker, names, tags) return tags.seafood and tags.seafood>=1 and tags.tuber and tags.meat and tags.meat <=1 and not tags.poultry and not tags.seed and not tags.inedible end,
        priority = 9,
        weight = 1,
        foodtype = "MEAT",
        health = TUNING.HEALING_MED,        -- 20
        hunger = TUNING.CALORIES_MED*2,        -- 50
        perishtime = TUNING.PERISH_FAST,    --  6
        sanity = TUNING.SANITY_TINY,        --  5
        cooktime = 2.00,
    }
AddCookerRecipe("cookpot", fish_n_chips_recipe)

 

So Im not sure why it would work in DS but not in DST.

 

Note: When testing in DST I spawned the items in rather than cooking them in the crock pot.

I'm not sure if that would make a difference.

Link to comment
Share on other sites

Just to be clear:

 

It increase health and hunger but not sanity?

And random question: why do you have a coma after TUNING.SANITY_TINY in the prefab item .lua?

 

yes it appears to be increasing health and hunger fine.

 

as to the comma? ummmm... should I not?

 

 

EDIT

--- ok - removed the comma and that fixed it.

 

Thanks

 

 

Edited by MidrealmDM
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...