Jump to content

Need help with making my prefab edible


Recommended Posts

Hey,

 

I downloaded the sample prefab template and I managed to get everything to work properly in-game without crashing, (images, .scml build, tex-files etc). But I can't figure out how to make it edible.. The goal for this prefab is to work together with my custom character to make him level up when eating it. I will try to add a custom recipe for the prefab later, but for now I just need help with the edible part. :-)

 

This is the code so far (scripts/prefabs/meatchunk.lua):

 

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

-- Write a local function that creats, customizes, and returns an instance of the prefab.
local function fn(Sim)
local inst = CreateEntity()
inst.entity:AddTransform()
inst.entity:AddAnimState()

MakeInventoryPhysics(inst)

inst.AnimState:SetBank("meatchunk")
inst.AnimState:SetBuild("meatchunk_build")
inst.AnimState:PlayAnimation("idle", true)

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

inst:AddComponent("inspectable")

return inst
end

-- Add some strings for this item
STRINGS.NAMES.MEATCHUNK = "Meatchunk"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.MEATCHUNK = "A bloody steak."


-- Finally, return a new prefab with the construction function and assets.
return Prefab( "common/inventory/meatchunk", fn, Assets)

 

So basically, I need a few lines of code to make this prefab edible.

 

Thanks in advance!

Best regards 

Batmanwarrior

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