Jump to content

Recommended Posts

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

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)
    end
end
AddPrefabPostInit("butterfly", modmydeployfunction)

 

 

Edited by Heavenfall

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
×
  • Create New...