2
0

init.lua 834 B

12345678910111213141516171819202122232425262728293031
  1. -- game_commands/init.lua
  2. -- Load support for MT game translation.
  3. local S = minetest.get_translator("game_commands")
  4. minetest.register_chatcommand("killme", {
  5. description = S("Kill yourself to respawn"),
  6. func = function(name)
  7. local player = minetest.get_player_by_name(name)
  8. if player then
  9. if minetest.settings:get_bool("enable_damage") then
  10. player:set_hp(0)
  11. return true
  12. else
  13. for _, callback in pairs(minetest.registered_on_respawnplayers) do
  14. if callback(player) then
  15. return true
  16. end
  17. end
  18. -- There doesn't seem to be a way to get a default spawn pos
  19. -- from the lua API
  20. return false, S("No static_spawnpoint defined")
  21. end
  22. else
  23. -- Show error message if used when not logged in, eg: from IRC mod
  24. return false, S("You need to be online to be killed!")
  25. end
  26. end
  27. })