~jadedctrl/gem-xwx-moe
~jadedctrl/gem-xwx-moe/gemujo_ludo/mods.niaj/fasado/killme/init.lua
~jadedctrl/gem-xwx-moe/gemujo_ludo/mods.niaj/fasado/killme/init.lua
0 | local S = minetest.get_translator("killme") |
1 |
|
2 | minetest.unregister_chatcommand("killme") |
3 |
|
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 | local pos = vector.round(player:getpos()) |
9 | if player then |
10 | if minetest.settings:get_bool("enable_damage") then |
11 | player:set_hp(0) |
12 | lightning.strike(pos) |
13 | return true |
14 | else |
15 | for _, callback in pairs(core.registered_on_respawnplayers) do |
16 | if callback(player) then |
17 | return true |
18 | end |
19 | end |
20 |
|
21 | -- There doesn't seem to be a way to get a default spawn pos from the lua API |
22 | return false, S("No static_spawnpoint defined") |
23 | end |
24 | else |
25 | -- Show error message if used when not logged in, eg: from IRC mod |
26 | return false, S("You need to be online to be killed!") |
27 | end |
28 | end |
29 | }) |