Jump to content

[Help code]Regen hp when your hunger is higher than 100 ??


Recommended Posts

Hi everyone, I really love the idea that create my own character in DST, every parts is complete but i still want add some unique ability to my character. Here are my ideas:
1) Health star regen slowly when your hunger is higher than 100
2) Regen 5 sanity whenever the character eating food
3) Move very slow when your hunger is lower than 20%

I try to add some code in prefabs\test.Lua with my little knowledge about coding but always got error when creating new world.
Can anyone help me (_ _")

Link to comment
Share on other sites

You should use DoPeriodicTask() for #1 and #3. e.g.:

inst:DoPeriodicTask( 2 ,function()
  --code here
end)

#2 can be done using the "oneat" event.

inst:ListenForEvent( "oneat", function()
  --code here
end)

You can raise stats using this function: inst.components.sanity:DoDelta(5)
You can also use TUNING.SANITY_TINY instead of 5, which can be dynamically tuned by other mods and updates.
For quiet raising, use: inst.components.health:DoDelta(1, true)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...