Batmanwarrior Posted January 2, 2015 Share Posted January 2, 2015 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 instend-- Add some strings for this itemSTRINGS.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 https://forums.kleientertainment.com/forums/topic/48204-need-help-with-making-my-prefab-edible/ Share on other sites More sharing options...
Kzisor Posted January 2, 2015 Share Posted January 2, 2015 You need to use the edible component. inst:AddComponent("edible") inst.components.edible.ismeat = true inst.components.edible.foodtype = "MEAT" Link to comment https://forums.kleientertainment.com/forums/topic/48204-need-help-with-making-my-prefab-edible/#findComment-595801 Share on other sites More sharing options...
Batmanwarrior Posted January 2, 2015 Author Share Posted January 2, 2015 Thank you very much Kzisor! Link to comment https://forums.kleientertainment.com/forums/topic/48204-need-help-with-making-my-prefab-edible/#findComment-595822 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now