igel69 Posted July 8, 2021 Share Posted July 8, 2021 (edited) Hello. I have this custom revival item called soul that you're supposed to haunt and get revived. After revival it's supposed to destroy itself. But it doesn't I would really apreciate it if someone could help me. soul.lua attached thanks in advance soul.lua Edited July 8, 2021 by igel69 Link to comment https://forums.kleientertainment.com/forums/topic/131657-destroy-revival-item-after-use/ Share on other sites More sharing options...
GearBull Posted July 8, 2021 Share Posted July 8, 2021 The thing you want to do looks like something Life-Giving Amulet does taking a look at it's code: this looks like something you want local function red() local inst = commonfn("redamulet", "resurrector", true) if not TheWorld.ismastersim then return inst end -- red amulet now falls off on death, so you HAVE to haunt it -- This is more straightforward for prototype purposes, but has side effect of allowing amulet steals -- inst.components.inventoryitem.keepondeath = true inst.components.equippable:SetOnEquip(onequip_red) inst.components.equippable:SetOnUnequip(onunequip_red) inst:AddComponent("finiteuses") inst.components.finiteuses:SetOnFinished(inst.Remove) inst.components.finiteuses:SetMaxUses(TUNING.REDAMULET_USES) inst.components.finiteuses:SetUses(TUNING.REDAMULET_USES) inst:AddComponent("hauntable") inst.components.hauntable:SetHauntValue(TUNING.HAUNT_INSTANT_REZ) return inst end 1 Link to comment https://forums.kleientertainment.com/forums/topic/131657-destroy-revival-item-after-use/#findComment-1477228 Share on other sites More sharing options...
Monti18 Posted July 8, 2021 Share Posted July 8, 2021 The problem probably lies in the fact that the game checks if it's a lifeamulet or not and then destroys it, as nothing else is destroying it. You could try adding a SetOnHauntFn to your prefab that checks if the haunter is a ghost and then removes it in the next frame. local function OnHaunt(inst,doer) if doer:HasTag("playerghost") then inst:DoTaskInTime(0,function(inst) inst:Remove() end) return true end end inst.components.hauntable:SetOnHauntFn(OnHaunt) 1 Link to comment https://forums.kleientertainment.com/forums/topic/131657-destroy-revival-item-after-use/#findComment-1477244 Share on other sites More sharing options...
igel69 Posted July 8, 2021 Author Share Posted July 8, 2021 1 hour ago, Monti18 said: The problem probably lies in the fact that the game checks if it's a lifeamulet or not and then destroys it, as nothing else is destroying it. You could try adding a SetOnHauntFn to your prefab that checks if the haunter is a ghost and then removes it in the next frame. local function OnHaunt(inst,doer) if doer:HasTag("playerghost") then inst:DoTaskInTime(0,function(inst) inst:Remove() end) return true end end inst.components.hauntable:SetOnHauntFn(OnHaunt) Wow, thanks so much. I have posted 3 times in this forum and every single time it was you helping me out and fixing it. I reallly apreciate it 1 Link to comment https://forums.kleientertainment.com/forums/topic/131657-destroy-revival-item-after-use/#findComment-1477263 Share on other sites More sharing options...
Monti18 Posted July 8, 2021 Share Posted July 8, 2021 Haha you're welcome! I'm happy I could help you 1 Link to comment https://forums.kleientertainment.com/forums/topic/131657-destroy-revival-item-after-use/#findComment-1477266 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