]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - builtin/client/death_formspec.lua
Merge branch 'master' of https://github.com/minetest/minetest
[dragonfireclient.git] / builtin / client / death_formspec.lua
index c25c799ab7fd3f48d79df208c3718986cf49fde5..ff484b32f6312e62796ebc61ee0364ee2044dc3b 100644 (file)
@@ -1,15 +1,38 @@
--- CSM death formspec. Only used when clientside modding is enabled, otherwise
--- handled by the engine.
+local death_formspec = ""
+       .. "size[11,5.5]"
+       .. "bgcolor[#320000b4;true]"
+       .. "label[4.85,1.35;" .. fgettext("You died") .. "]"
+       .. "button_exit[2,3;3,0.5;btn_respawn;" .. fgettext("Respawn") .. "]"
+       .. "button_exit[6,3;3,0.5;btn_ghost_mode;" .. "Ghost Mode" .. "]"
+       .. "set_focus[btn_respawn;true]"
 
 core.register_on_death(function()
-       local formspec = "size[11,5.5]bgcolor[#320000b4;true]" ..
-               "label[4.85,1.35;" .. fgettext("You died") ..
-               "]button_exit[4,3;3,0.5;btn_respawn;".. fgettext("Respawn") .."]"
-       core.show_formspec("bultin:death", formspec)
+       core.display_chat_message("You died at " .. core.pos_to_string(vector.round(core.localplayer:get_pos())) .. ".")
+       if core.settings:get_bool("autorespawn") then
+               core.send_respawn()
+       else
+               core.show_formspec("bultin:death", death_formspec)
+       end
 end)
 
 core.register_on_formspec_input(function(formname, fields)
        if formname == "bultin:death" then
-               core.send_respawn()
+               if fields.btn_ghost_mode then
+                       core.display_chat_message("You are in ghost mode. Use .respawn to Respawn.")
+               else
+                       core.send_respawn()
+               end
        end
 end)
+
+core.register_chatcommand("respawn", {
+       description = "Respawn when in ghost mode",
+       func = function()
+               if core.localplayer:get_hp() == 0 then
+                       core.send_respawn()
+                       core.display_chat_message("Respawned.")
+               else
+                       core.display_chat_message("You are not in ghost mode.")
+               end
+       end
+})