TiagoAbreuReal Posted August 20, 2015 Share Posted August 20, 2015 this function: local function onhaunt(inst) inst:Remove()endPlease anyone can tell me why not work?how should I do to destroy an item after haunt,Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/57209-help-removing-item-after-haunt/ Share on other sites More sharing options...
Blueberrys Posted August 20, 2015 Share Posted August 20, 2015 @TiagoAbreuReal-- where inst is the hauntable itemlocal old_onhaunt = inst.components.hauntable.onhauntinst.components.hauntable:SetOnHauntFn(function(inst, doer) -- Do something return old_onhaunt(inst, doer)end) Link to comment https://forums.kleientertainment.com/forums/topic/57209-help-removing-item-after-haunt/#findComment-665007 Share on other sites More sharing options...
TiagoAbreuReal Posted August 20, 2015 Author Share Posted August 20, 2015 @TiagoAbreuReal-- where inst is the hauntable itemlocal old_onhaunt = inst.components.hauntable.onhauntinst.components.hauntable:SetOnHauntFn(function(inst, doer) -- Do something return old_onhaunt(inst, doer)end) This code inside: local function fn()return instendPlease, look my code full: local assets ={Asset("ANIM", "anim/r_shelter.zip"),Asset("SOUND", "sound/common.fsb"),}local function onhaunt(inst) inst.AnimState:PlayAnimation("idle")inst.AnimState:PushAnimation("idle", true)inst.SoundEmitter:PlaySound("dontstarve/common/resurrectionstone_activate") end-- Classe que adiciona os atributos ao item e define sua caracteristicalocal function fn() local inst = CreateEntity() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() local netw = inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("r_shelter") inst.AnimState:SetBuild("r_shelter") inst.AnimState:PlayAnimation("idle", true)inst:AddTag("structure") inst:AddTag("shelter") if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() -- Add o componente de inspecionar o item inst:AddComponent("inspectable") inst.components.inspectable:RecordViews() -- / Add o componente de inspecionar o item -- Add o item ao inventario inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "r_shelter" inst.components.inventoryitem.atlasname = "images/inventoryimages/r_shelter.xml" -- / Add o item ao inventario -- Add o componente de assombrar o item inst:AddComponent("hauntable") inst.components.hauntable:SetHauntValue(TUNING.HAUNT_INSTANT_REZ) -- / Add o componente de assombrar o item return instendreturn Prefab( "common/r_shelter", fn, assets),MakePlacer( "common/r_shelter_placer", "r_shelter", "r_shelter", "idle" ) Link to comment https://forums.kleientertainment.com/forums/topic/57209-help-removing-item-after-haunt/#findComment-665053 Share on other sites More sharing options...
TiagoAbreuReal Posted August 21, 2015 Author Share Posted August 21, 2015 I finished, thank you! Link to comment https://forums.kleientertainment.com/forums/topic/57209-help-removing-item-after-haunt/#findComment-665134 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