2019-09-10 19:09:51 +02:00
|
|
|
-- game_commands/init.lua
|
|
|
|
|
|
|
|
-- Load support for MT game translation.
|
|
|
|
local S = minetest.get_translator("game_commands")
|
|
|
|
|
|
|
|
|
2017-01-02 16:44:15 +01:00
|
|
|
minetest.register_chatcommand("killme", {
|
2019-09-10 19:09:51 +02:00
|
|
|
description = S("Kill yourself to respawn"),
|
2017-01-02 16:44:15 +01:00
|
|
|
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
|
2017-01-02 16:44:15 +01:00
|
|
|
player:set_hp(0)
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
for _, callback in pairs(core.registered_on_respawnplayers) do
|
|
|
|
if callback(player) then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-24 20:08:06 +02:00
|
|
|
-- There doesn't seem to be a way to get a default spawn pos
|
|
|
|
-- from the lua API
|
2019-09-10 19:09:51 +02:00
|
|
|
return false, S("No static_spawnpoint defined")
|
2017-01-02 16:44:15 +01:00
|
|
|
end
|
|
|
|
else
|
|
|
|
-- Show error message if used when not logged in, eg: from IRC mod
|
2019-09-10 19:09:51 +02:00
|
|
|
return false, S("You need to be online to be killed!")
|
2017-01-02 16:44:15 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|