init.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. if not minetest.global_exists("hunger") then hunger = {} end
  2. hunger.modpath = minetest.get_modpath("hunger")
  3. hunger.players = hunger.players or {}
  4. hunger.food = hunger.food or {}
  5. HUNGER_TICK = 60 -- time in seconds after that 1 hunger point is taken
  6. HUNGER_HEALTH_TICK = 10 -- time in seconds after player gets healed/damaged
  7. HUNGER_MOVE_TICK = 2 -- time in seconds after the movement is checked
  8. HUNGER_EXHAUST_DIG = 5 -- exhaustion increased this value after digged node
  9. HUNGER_EXHAUST_PLACE = 4 -- exhaustion increased this value after placed
  10. HUNGER_EXHAUST_MOVE = 0.5 -- exhaustion increased this value if player movement detected
  11. HUNGER_EXHAUST_LVL = 150 -- at what exhaustion player saturation gets lowered
  12. HUNGER_HEAL = 0.05 -- percentage of HP player gets healed after HUNGER_HEALTH_TICK
  13. HUNGER_HEAL_LVL = 15 -- lower level of saturation needed to get healed
  14. HUNGER_STARVE = 0.05 -- percentage of HP player gets damaged by hunger after HUNGER_HEALTH_TICK
  15. HUNGER_STARVE_LVL = 4 -- level of staturation that causes starving
  16. HUNGER_MAX = 30 -- maximum level of saturation
  17. dofile(hunger.modpath .. "/functions.lua")
  18. dofile(hunger.modpath .. "/hp_boost.lua")
  19. dofile(hunger.modpath .. "/hp_regen_boost.lua")
  20. dofile(hunger.modpath .. "/sta_regen_boost.lua")
  21. dofile(hunger.modpath .. "/resistance.lua")
  22. dofile(hunger.modpath .. "/hot.lua")
  23. dofile(hunger.modpath .. "/diet.lua")
  24. -- Putting this inside minetest.after() avoids having to declare dependencies.
  25. minetest.after(0, function()
  26. dofile(hunger.modpath .. "/food.lua")
  27. end)
  28. if not hunger.run_once then
  29. hunger.run_once = true
  30. core.do_item_eat = function(...) return hunger.do_item_eat(...) end
  31. -- Public API function, to be used in place of 'minetest.item_eat' where needed.
  32. function hunger.item_eat(...) return hunger.item_eat2(...) end
  33. minetest.register_on_joinplayer(function(...) return hunger.on_joinplayer(...) end)
  34. minetest.register_on_respawnplayer(function(...) return hunger.on_respawnplayer(...) end)
  35. minetest.register_on_leaveplayer(function(...) return hunger.on_leaveplayer(...) end)
  36. minetest.register_on_placenode(function(...) return hunger.on_placenode(...) end)
  37. minetest.register_on_dignode(function(...) return hunger.on_dignode(...) end)
  38. minetest.register_globalstep(function(...) return hunger.on_globalstep(...) end)
  39. minetest.register_on_dieplayer(function(...) return hunger.on_dieplayer(...) end)
  40. local c = "hunger:core"
  41. local f = hunger.modpath .. "/init.lua"
  42. reload.register_file(c, f, false)
  43. end