init.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. beds = {}
  2. beds.modpath = minetest.get_modpath("beds")
  3. beds.player = {}
  4. beds.pos = {}
  5. beds.spawn = {}
  6. beds.storage = minetest.get_mod_storage()
  7. beds.formspec = "size[8,15;true]" ..
  8. "bgcolor[#080808BB; true]" ..
  9. "button_exit[2,12;4,0.75;leave;Leave Bed]"
  10. local modpath = minetest.get_modpath("beds")
  11. -- Load files
  12. dofile(modpath .. "/functions.lua")
  13. dofile(modpath .. "/api.lua")
  14. dofile(modpath .. "/beds.lua")
  15. dofile(modpath .. "/spawns.lua")
  16. minetest.register_privilege("nobeds", {
  17. description = "Player does not require sleep.",
  18. give_to_singleplayer = false,
  19. })
  20. minetest.register_on_respawnplayer(function(...)
  21. return beds.on_respawnplayer(...)
  22. end)
  23. minetest.register_on_joinplayer(function(...)
  24. return beds.on_joinplayer(...)
  25. end)
  26. minetest.register_on_leaveplayer(function(...)
  27. return beds.on_leaveplayer(...)
  28. end)
  29. minetest.register_on_player_receive_fields(function(...)
  30. return beds.on_player_receive_fields(...)
  31. end)
  32. minetest.register_chatcommand("check_bed", {
  33. params = "",
  34. description = "Check bed-respawn status.",
  35. privs = {},
  36. func = function(pname, param)
  37. beds.report_respawn_status(pname)
  38. return true
  39. end,
  40. })