init.lua 693 B

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