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.

Taob

Can't find prefab

Recommended Posts

Taob    0

I'm trying to port the Leafy Meat recipes to Don't Starve, I don't see the image of the food on the crock pot.
A message is printed on the console : "Can't find prefab leafymeatsouffle".
I already put the prefab on modmain.lua

local assets =
{
    Asset("ANIM", "anim/cook_pot_food4.zip"),
}

local prefabs =
{
    "spoiled_food",
}

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("cook_pot_food4")
    inst.AnimState:SetBuild("cook_pot_food4")
    inst.AnimState:PlayAnimation("idle")

    MakeInventoryFloatable(inst, "small", 0.2, 0.95)

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end
    inst:AddComponent("inspectable")
    inst:AddComponent("inventoryitem")

    inst:AddComponent("edible")
    inst.components.edible.foodtype = "MEAT"
    inst.components.edible.healthvalue = TUNING.CALORIES_LARGE
    inst.components.edible.hungervalue = TUNING.PERISH_FAST
    inst.components.edible.sanityvalue = TUNING.SANITY_HUGE

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

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

    inst.replica.inventoryitem:SetImage("leafymeatsouffle")
    inst.components.inventoryitem.atlasname = "images/inventoryimages/leafymeatsouffle.xml"

    MakeHauntableLaunch(inst)

    return inst
end

return Prefab("common/inventory/leafymeatsouffle", fn, assets, prefabs )

log.txt

Share this post


Link to post
Share on other sites
krylincy    53

1) the error message in your attached log is "Could not find anim build leafymeatsouffle". is the animation ok? and is the name correct? 

2) you are talking about ds not dst? there is no "replica". you should remove it ( inst.replica.inventoryitem:SetImage("leafymeatsouffle"))

3) i think you need to import the inventory images too, not only the animation

local assets =
{
	Asset("ANIM", "anim/XX.zip"),	
    Asset("ATLAS", "images/inventoryimages/XX.xml"),
    Asset("IMAGE", "images/inventoryimages/XX.tex"),
}

 

Share this post


Link to post
Share on other sites
krylincy    53

can you cahnge the code to use a default image that is already in the game? to verify if it is a problem with the image itself or the integration?

Share this post


Link to post
Share on other sites