init.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --[[
  2. Thirsty mod [thirsty]
  3. ==========================
  4. A mod that adds a "thirst" mechanic, similar to hunger.
  5. Copyright (C) 2015 Ben Deutsch <ben@bendeutsch.de>
  6. License
  7. -------
  8. This library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Lesser General Public
  10. License as published by the Free Software Foundation; either
  11. version 2.1 of the License, or (at your option) any later version.
  12. This library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Lesser General Public License for more details.
  16. You should have received a copy of the GNU Lesser General Public
  17. License along with this library; if not, write to the Free Software
  18. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
  19. USA
  20. Terminology: "Thirst" vs. "hydration"
  21. -------------------------------------
  22. "Thirst" is the absence of "hydration" (a term suggested by
  23. everamzah on the Minetest forums, thanks!). The overall mechanic
  24. is still called "thirst", but the visible bar is that of
  25. "hydration", filled with "hydro points".
  26. ]]
  27. -- the main module variable
  28. thirsty = {
  29. -- Configuration variables
  30. config = {
  31. -- configuration in thirsty.default.conf
  32. },
  33. -- the players' values
  34. players = {
  35. --[[
  36. name = {
  37. last_pos = '-10:3',
  38. time_in_pos = 0.0,
  39. pending_dmg = 0.0,
  40. thirst_factor = 1.0,
  41. }
  42. ]]
  43. },
  44. -- water fountains
  45. fountains = {
  46. --[[
  47. x:y:z = {
  48. pos = { x=x, y=y, z=z },
  49. level = 4,
  50. time_until_check = 20,
  51. -- something about times
  52. }
  53. ]]
  54. },
  55. -- general settings
  56. time_next_tick = 0.0,
  57. }
  58. local M = thirsty
  59. dofile(minetest.get_modpath('thirsty')..'/configuration.lua')
  60. local C = M.config
  61. dofile(minetest.get_modpath('thirsty')..'/persistent_player_attributes.lua')
  62. local PPA = M.persistent_player_attributes
  63. thirsty.time_next_tick = thirsty.config.tick_time
  64. dofile(minetest.get_modpath('thirsty')..'/hud.lua')
  65. dofile(minetest.get_modpath('thirsty')..'/functions.lua')
  66. minetest.register_on_joinplayer(thirsty.on_joinplayer)
  67. minetest.register_on_dieplayer(thirsty.on_dieplayer)
  68. minetest.register_globalstep(thirsty.main_loop)
  69. dofile(minetest.get_modpath('thirsty')..'/components.lua')