Skorp Posted March 28, 2014 Share Posted March 28, 2014 In the krampused.lua there is this function: self.inst:ListenForEvent( "killed", function(inst,data) self:onkilledother(data.victim) end ) which is later called for this: function Kramped:onkilledother(victim) if victim and victim.prefab then if victim.prefab == "pigman" then if not victim.components.werebeast or not victim.components.werebeast:IsInWereState() then self:OnNaughtyAction(8) end I'm trying to make planting butterflies change the naughty counter but I don't know what data is in the action of "growfrombutterfly" to work like the murdered code local function OnDeploy (inst, pt) local flower = SpawnPrefab("flower") if flower then flower:PushEvent("growfrombutterfly") flower.Transform:SetPosition(pt.x, pt.y, pt.z) inst.components.stackable:Get():Remove() end Any tips? Link to comment https://forums.kleientertainment.com/forums/topic/33714-listen-for-event/ Share on other sites More sharing options...
Heavenfall Posted March 28, 2014 Share Posted March 28, 2014 (edited) There's no event for that, you can hook into the deploy function from modmain though function modmydeployfunction(inst) oldOnDeploy = inst.components.deployable.ondeploy inst.components.deployable.ondeploy = function(inst, pt) if GLOBAL.GetPlayer() and GLOBAL.GetPlayer().components.kramped then GLOBAL.GetPlayer().components.kramped:OnNaughtyAction(5) end oldOnDeploy(inst, pt) endendAddPrefabPostInit("butterfly", modmydeployfunction) Edited March 28, 2014 by Heavenfall Link to comment https://forums.kleientertainment.com/forums/topic/33714-listen-for-event/#findComment-439554 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