Sign in to follow this  
Draukel

Have sanity back when I'm hitted

Recommended Posts

Draukel    1

Hello everyone, one again I ask about sanity stuff.

For this question is just if I can code something like "I gain 10 sanity point when I take damage" (don't ask me what character I made, that's...Weird...But in don't starve universe it's normal I guess), I know it's possible, I've successfully coded an effect for loose sanity in day and gain it in night.

Or maybe I'm wrong? I don't know, but I prefer to try. If you think you have the answer, a reply is welcome. Don't be afraid, I don't bite, not every time èwé

Share this post


Link to post
Share on other sites
Lumina    1,516

Yes. You need to add a "listenforevent" in your character masterpostinit, with the even of being attacked (don't remember which one it's exactly), and make your custom function that will trigger when attacked.

Share this post


Link to post
Share on other sites
Draukel    1
5 minutes ago, Lumina said:

Yes. You need to add a "listenforevent" in your character masterpostinit, with the even of being attacked (don't remember which one it's exactly), and make your custom function that will trigger when attacked.

So I do
 

Quote

 inst:ListenForEvent("something I didn't found yet", function(data)
     if data.cause == inst.prefab then
        local delta = 10 -- amount
        inst.components.health:DoDelta(delta)
end

Right?

Share this post


Link to post
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

Sign in to follow this