1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-11-15 06:20:19 +01:00
minetest_game/mods/game_commands/init.lua

32 lines
834 B
Lua
Raw Normal View History

-- game_commands/init.lua
-- Load support for MT game translation.
local S = minetest.get_translator("game_commands")
minetest.register_chatcommand("killme", {
description = S("Kill yourself to respawn"),
func = function(name)
local player = minetest.get_player_by_name(name)
if player then
2017-05-22 15:41:17 +02:00
if minetest.settings:get_bool("enable_damage") then
player:set_hp(0)
return true
else
2019-12-29 12:28:30 +01:00
for _, callback in pairs(minetest.registered_on_respawnplayers) do
if callback(player) then
return true
end
end
-- There doesn't seem to be a way to get a default spawn pos
-- from the lua API
return false, S("No static_spawnpoint defined")
end
else
-- Show error message if used when not logged in, eg: from IRC mod
return false, S("You need to be online to be killed!")
end
end
})