tdtbaa Posted March 17, 2016 Share Posted March 17, 2016 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! Link to comment https://forums.kleientertainment.com/forums/topic/65509-any-code-to-lose-sanity-when-killing-something-specific/ Share on other sites More sharing options...
CarlZalph Posted March 18, 2016 Share Posted March 18, 2016 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 ) Link to comment https://forums.kleientertainment.com/forums/topic/65509-any-code-to-lose-sanity-when-killing-something-specific/#findComment-735334 Share on other sites More sharing options...
tdtbaa Posted March 18, 2016 Author Share Posted March 18, 2016 (edited) 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 March 18, 2016 by tdtbaa misplaced letter Link to comment https://forums.kleientertainment.com/forums/topic/65509-any-code-to-lose-sanity-when-killing-something-specific/#findComment-735361 Share on other sites More sharing options...
CarlZalph Posted March 18, 2016 Share Posted March 18, 2016 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. Link to comment https://forums.kleientertainment.com/forums/topic/65509-any-code-to-lose-sanity-when-killing-something-specific/#findComment-735438 Share on other sites More sharing options...
tdtbaa Posted March 18, 2016 Author Share Posted March 18, 2016 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! ¦') Link to comment https://forums.kleientertainment.com/forums/topic/65509-any-code-to-lose-sanity-when-killing-something-specific/#findComment-735568 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