init.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. if not minetest.global_exists("welcome") then welcome = {} end
  2. welcome.modpath = minetest.get_modpath("welcome_msg")
  3. -- Timeout in seconds.
  4. welcome.timeout = tonumber(minetest.settings:get("welcome_msg_delay") or 15)
  5. welcome.timeout2 = tonumber(minetest.settings:get("welcome_msg_delay2") or 30)
  6. -- The welcome message.
  7. welcome.message = minetest.settings:get("welcome_msg_string") or "Welcome!"
  8. welcome.message2 = minetest.settings:get("welcome_msg_string2")
  9. welcome.color = core.get_color_escape_sequence("#ff00ff")
  10. welcome.on_timer = function(pname)
  11. local player = minetest.get_player_by_name(pname)
  12. if not player then return end -- Player doesn't exist anymore.
  13. minetest.chat_send_player(pname, welcome.color .. "# Server: " .. welcome.message)
  14. end
  15. welcome.on_timer2 = function(pname)
  16. local player = minetest.get_player_by_name(pname)
  17. if not player then return end -- Player doesn't exist anymore.
  18. if welcome.message2 then
  19. minetest.chat_send_player(pname, welcome.color .. "# Server: " .. welcome.message2)
  20. end
  21. end
  22. welcome.on_joinplayer = function(player)
  23. if not player or not player:is_player() then return end
  24. local pname = player:get_player_name()
  25. if banned_names.guest_name(pname) then
  26. minetest.after(10, function() minetest.chat_send_player(pname, "# Server: WARNING! You have logged in using a \"guest name\". Please be aware that such accounts are subject to deletion WITHOUT WARNING. You are still free to explore the server, though! If you want to play permanently, log in under another (non-guest) name and register the account by crafting and keeping a Proof of Citizenship.") end)
  27. return
  28. end
  29. --[[
  30. local pname = player:get_player_name()
  31. if passport.player_registered(pname) then return end
  32. minetest.after(welcome.timeout, welcome.on_timer, pname)
  33. minetest.after(welcome.timeout2, welcome.on_timer2, pname)
  34. --]]
  35. end
  36. if not welcome.init_done then
  37. minetest.register_on_joinplayer(function(...)
  38. return welcome.on_joinplayer(...) end)
  39. -- Support for mod reloading, if available.
  40. if minetest.get_modpath("reload") then
  41. local args = {
  42. "welcome:core",
  43. welcome.modpath .. "/init.lua",
  44. false,
  45. }
  46. reload.register_file(unpack(args))
  47. end
  48. dofile(welcome.modpath .. "/joinspec.lua")
  49. welcome.init_done = true
  50. end