Jump to content

[Moding Help]


Recommended Posts

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
Share on other sites

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)end

You forgot to include the event listener for things killed.

Link to comment
Share on other sites

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)end

You 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
Share on other sites

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
 Share

×
  • Create New...