58 lines
1.6 KiB
Lua
Raw Normal View History

2022-02-15 14:28:14 +05:00
local DWP = nil
local DP
2022-02-18 00:36:15 +05:00
local function setdwp()
if not DWP then
DWP = core.localplayer:hud_add({
hud_elem_type = "waypoint",
name = "DeathPoint",
number = 0xFF0000,
world_pos = DP})
if not DWP then return end
else
core.localplayer:hud_change(DWP,'world_pos',DP)
end
end
2022-01-31 11:28:31 +05:00
core.register_on_death(function()
2022-02-15 14:28:14 +05:00
DP = core.localplayer:get_pos()
2022-02-18 00:36:15 +05:00
core.display_chat_message(minetest.colorize("#F00","You died at "..core.pos_to_string(vector.round(DP))))
core.show_formspec("cdf", "size[4,4.2]"..
"label[1.45,0;"..fgettext("You died")..
2022-05-31 12:40:20 +05:00
"]button_exit[1,1;2,0.5;respawn;"..fgettext("Respawn")..
"]set_focus[ghostmode;true"..
2022-02-18 00:36:15 +05:00
"]button_exit[1,2;2,0.5;ghostmode;GhostMode"..
"]button_exit[1,3;2,0.5;disconnect;"..fgettext("Exit to Menu")..
2022-05-31 12:40:20 +05:00
"]checkbox[1,3.8;dpoint;Set DeathPoint;false]set_focus[ghostmode]")
2022-01-28 10:11:28 +05:00
end)
core.register_on_formspec_input(function(formname, fields)
2022-01-31 02:55:43 +05:00
if formname == "cdf" then
2022-02-18 00:36:15 +05:00
if fields.dpoint then setdwp()
elseif fields.disconnect then
core.disconnect()
2022-02-18 00:36:15 +05:00
elseif fields.respawn then
core.send_respawn()
2022-02-15 14:28:14 +05:00
else
core.display_chat_message(minetest.colorize("#FF0","GhostMode active. Type '.resp' to respawn."))
2022-02-18 00:36:15 +05:00
end
2022-01-28 10:11:28 +05:00
end
end)
core.register_chatcommand("resp", {
description = "Respawn from GhostMode",
func = function()
if core.localplayer:get_hp() == 0 then
core.send_respawn()
else
2022-02-15 14:28:14 +05:00
core.display_chat_message(minetest.colorize("#FF0","You're alive yet ;)"))
2022-01-28 10:11:28 +05:00
end
2022-02-15 14:28:14 +05:00
end})
core.register_chatcommand("rdp", {
description = "Remove death waypoint",
func = function()
if DWP then
core.localplayer:hud_remove(DWP)
DWP = nil
end
end})