functions.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function hud.read_conf()
  2. local mod_path = minetest.get_modpath("hud")
  3. local set = io.open(mod_path .. "/hud.conf", "r")
  4. if set then
  5. dofile(mod_path .. "/hud.conf")
  6. set:close()
  7. end
  8. end
  9. function hud.notify_hunger(delay, use)
  10. local txt_part = "enable"
  11. if use then
  12. txt_part = "use"
  13. end
  14. minetest.after(delay, function()
  15. minetest.chat_send_all("#Better HUD: You can't " .. txt_part .. " hunger without the \"hunger\" mod")
  16. minetest.chat_send_all(" Enable it or download it from \"https://github.com/BlockMen/hunger\"")
  17. end)
  18. end
  19. function hud.player_event(player, event)
  20. --needed for first update called by on_join
  21. minetest.after(0, function()
  22. if event == "health_changed" then
  23. for _,v in pairs(hud.damage_events) do
  24. if v.func then
  25. v.func(player)
  26. end
  27. end
  28. end
  29. if event == "breath_changed" then
  30. for _,v in pairs(hud.breath_events) do
  31. if v.func then
  32. v.func(player)
  33. end
  34. end
  35. end
  36. if event == "hud_changed" then--called when flags changed
  37. end
  38. end)
  39. end
  40. core.register_playerevent(hud.player_event)