]> git.lizzy.rs Git - dragonfireclient.git/blob - builtin/client/cheats/player.lua
World Cheats improvements; Add BlockLava; Readd minetest.request_http_api for Compati...
[dragonfireclient.git] / builtin / client / cheats / player.lua
1 local death_formspec = ""
2         .. "size[11,5.5]"
3         .. "bgcolor[#320000b4;true]"
4         .. "label[4.85,1.35;" .. "You died" .. "]"
5         .. "button_exit[2,3;3,0.5;btn_respawn;" .. "Respawn" .. "]"
6         .. "button_exit[6,3;3,0.5;btn_ghost_mode;" .. "Ghost Mode" .. "]"
7         .. "set_focus[btn_respawn;true]"
8
9 core.register_on_death(function()
10         core.display_chat_message("You died at " .. core.pos_to_string(vector.round(core.localplayer:get_pos())) .. ".")
11         if core.settings:get_bool("autorespawn") then
12                 core.send_respawn()
13         else
14                 core.show_formspec("__builtin__:death", death_formspec)
15         end
16 end)
17
18 core.register_on_formspec_input(function(formname, fields)
19         if formname == "__builtin__:death" then
20                 if fields.btn_ghost_mode then
21                         core.display_chat_message("You are in ghost mode. Use .respawn to Respawn.")
22                 else
23                         core.send_respawn()
24                 end
25         end
26 end)
27
28 core.register_chatcommand("respawn", {
29         description = "Respawn when in ghost mode",
30         func = function()
31                 if core.localplayer:get_hp() == 0 then
32                         core.send_respawn()
33                         core.display_chat_message("Respawned.")
34                 else
35                         core.display_chat_message("You are not in ghost mode.")
36                 end
37         end
38 })
39