undying: huge improvements!

This commit is contained in:
cora 2020-11-26 23:08:09 +01:00
parent a14b6aaf11
commit b451b280b0
2 changed files with 37 additions and 17 deletions

View File

@ -9,11 +9,11 @@ local formspec = ""
.. "set_focus[btn_respawn;true]" .. "set_focus[btn_respawn;true]"
minetest.register_on_death(function() minetest.register_on_death(function()
local warp_success, warp_msg = warp.set_here("death") if minetest.settings:get_bool("deathwarp") then
if warp_success then local warp_success, warp_msg = warp.set_here("death")
minetest.display_chat_message(warp_msg) if warp_success then
else minetest.display_chat_message(warp_msg)
minetest.display_chat_message("You died at " .. minetest.pos_to_string(minetest.localplayer:get_pos()) .. ".") end
end end
if minetest.settings:get_bool("autorespawn") then if minetest.settings:get_bool("autorespawn") then
minetest.send_respawn() minetest.send_respawn()
@ -45,3 +45,4 @@ minetest.register_chatcommand("respawn", {
}) })
minetest.register_cheat("AutoRespawn", "Player", "autorespawn") minetest.register_cheat("AutoRespawn", "Player", "autorespawn")
minetest.register_cheat("DeathWarp", "Player", "deathwarp")

View File

@ -2,30 +2,49 @@
-- undying -- undying
local sh=false
local function findbones()
return minetest.find_node_near(minetest.localplayer:get_pos(), 6, {"bones:bones"},true)
end
local function digbones()
local bn=findbones()
if not bn then return false end
minetest.dig_node(bn)
if findbones() then minetest.after("0.1",digbones) end
end
minetest.register_on_death(function() minetest.register_on_death(function()
if not minetest.settings:get_bool("undying") then return end if not minetest.settings:get_bool("undying") then return end
minetest.after(0.2,function() sh=false
minetest.send_chat_message("/home") minetest.after("0.1",function() minetest.send_chat_message("/home") end)
minetest.after(1.0,function() minetest.after("0.2",function()
local bn=minetest.find_node_near(minetest.localplayer:get_pos(), 6, {"bones:bones"},true) digbones()
if not bn then return end for k, v in ipairs(minetest.localplayer.get_nearby_objects(10)) do
minetest.dig_node(bn) if (v:is_player() and v:get_name() ~= minetest.localplayer:get_name()) then
end) local pos = v:get_pos()
pos.y = pos.y - 1
autofly.aim(pos)
end
end
end) end)
end) end)
minetest.register_on_damage_taken(function(hp) minetest.register_on_damage_taken(function(hp)
local hhp=minetest.localplayer:get_hp() if not sh and minetest.settings:get_bool("undying") then
if (hhp==0 ) then return end local hhp=minetest.localplayer:get_hp()
if (hhp < 3 ) then --if (hhp==0 ) then return end
if minetest.settings:get_bool("undying") then if (hhp < 2 ) then
sh=true
minetest.settings:set_bool("autorespawn",true) minetest.settings:set_bool("autorespawn",true)
minetest.send_chat_message("/sethome") end minetest.send_chat_message("/sethome") end
end end
end end
) )
minetest.register_on_receiving_chat_message(function(msg)
if (msg:find('Teleported to home!') or msg:find('Home set!')) then return true end
end)
-- REG cheats on DF -- REG cheats on DF
if (_G["minetest"]["register_cheat"] ~= nil) then if (_G["minetest"]["register_cheat"] ~= nil) then