Aliekat Posted April 25, 2015 Share Posted April 25, 2015 I have been trying to finish coding my custom character but ran into an issue. I can't get the coding correct so she loses sanity when she kills a rabbit, bird, or mole. I based the code on Wigrid's ability to gain sanity, but still can't get it to work. This is what I have so far:local function onkilled(inst, data) local victim = data.victim if victim:HasTag("rabbit") or victim:HasTag("mole") or victim:HasTag("crow") or victim:HasTag("robin") or victim:HasTag("robin_winter") then inst.components.sanity:DoDelta(TUNING.CRAZINESS_SMALL) endend Link to comment https://forums.kleientertainment.com/forums/topic/53176-moding-help/ Share on other sites More sharing options...
DarkXero Posted April 25, 2015 Share Posted April 25, 2015 local function onkilled(inst, data) local victim = data.victim if victim:HasTag("rabbit") or victim:HasTag("mole") or victim:HasTag("crow") or victim:HasTag("robin") or victim:HasTag("robin_winter") then inst.components.sanity:DoDelta(-TUNING.CRAZINESS_SMALL) endendlocal function master_postinit(inst) -- other code you have goes here inst:ListenForEvent("killed", onkilled)endYou forgot to include the event listener for things killed. Link to comment https://forums.kleientertainment.com/forums/topic/53176-moding-help/#findComment-632090 Share on other sites More sharing options...
Aliekat Posted April 25, 2015 Author Share Posted April 25, 2015 Ah, after hours of coding it was a simple placement error haha. nevermind.local function onkilled(inst, data) local victim = data.victim if victim:HasTag("rabbit") or victim:HasTag("mole") or victim:HasTag("crow") or victim:HasTag("robin") or victim:HasTag("robin_winter") then inst.components.sanity:DoDelta(-TUNING.CRAZINESS_SMALL) endendlocal function master_postinit(inst) -- other code you have goes here inst:ListenForEvent("killed", onkilled)endYou forgot to include the event listener for things killed. Thank you haha, that was what I realized too, it's works great now, thanks for the help ^^ Link to comment https://forums.kleientertainment.com/forums/topic/53176-moding-help/#findComment-632091 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