Jump to content

Recommended Posts

Like if I were to kill a crow and I wanted to lose 2 sanity for it, what would I have to put in there? (Assuming that status effects on specific kills is a possibility)

I have this in (I know it doesn't work, I'm new to this)

inst:ListenForEvent("killed",function(inst,data)
    if killed.prefab == "crow" then 
         inst.components.sanity:DoDelta(-2)
    end

Any help would be appreciated! 

I haven't touched DS's codebase in a while, but for DST's it'd be:

 

AddPrefabPostInit("wilson",
    function(inst)
        inst:ListenForEvent("killed",
            function(inst, data)
                local victim = data.victim
                if(victim~=nil and victim.prefab=="crow")
                then
                    inst.components.sanity:DoDelta(-2)
                end
            end
        )
    end
)

 

1 hour ago, CarlZalph said:

I haven't touched DS's codebase in a while, but for DST's it'd be:

 

AddPrefabPostInit("wilson",
    function(inst)
        inst:ListenForEvent("killed",
            function(inst, data)
                local victim = data.victim
                if(victim~=nil and victim.prefab=="crow")
                then
                    inst.components.sanity:DoDelta(-2)
                end
            end
        )
    end
)

I'm afraid that didn't do anything except crash my game (and I renamed Wilson to my character name (and I even removed some lines and tried them without some lines and with others)). But thank you for trying! UoU

Edited by tdtbaa
misplaced letter
1 hour ago, tdtbaa said:

 

I'm afraid that didn't do anything except crash my game (and I renamed Wilson to my character name (and I even removed some lines and tried them without some lines and with others)). But thank you for trying! UoU

Redownloaded DS, and tested what I provided.

 

Didn't crash and also applied the negative sanity on killing of the crow bird type.

Are you trying to shove this into a custom character, or applying it to an already made one?

If it's into a custom character then only add the bit with:

inst:ListenForEvent("killed",
    function(inst, data)
        local victim = data.victim
        if(victim~=nil and victim.prefab=="crow")
        then
            inst.components.sanity:DoDelta(-2)
        end
    end
)

 

In the character's initialization function callback.

12 hours ago, CarlZalph said:

Redownloaded DS, and tested what I provided.

 

Didn't crash and also applied the negative sanity on killing of the crow bird type.

Are you trying to shove this into a custom character, or applying it to an already made one?

If it's into a custom character then only add the bit with:

inst:ListenForEvent("killed",
    function(inst, data)
        local victim = data.victim
        if(victim~=nil and victim.prefab=="crow")
        then
            inst.components.sanity:DoDelta(-2)
        end
    end
)

 

In the character's initialization function callback.

Thank you! I had it placed in the wrong place and had an unused ")" that was ruining my character's prefab u_u

It works now though! Thanks! ¦')

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...