Allow setting dont_heal from other mods

This commit is contained in:
LoneWolfHT 2020-12-02 11:51:21 -08:00
parent 8d55487a77
commit 0e79443fb5

View file

@ -64,19 +64,19 @@ minetest.register_globalstep(function(delta)
regen_update()
end)
local dont_heal = {}
ctf_classes.dont_heal = {}
minetest.register_on_player_hpchange(function(player, hp_change, reason)
local name = player:get_player_name()
if reason.type == "drown" or reason.type == "node_damage" then
dont_heal[name] = true
elseif dont_heal[name] then
dont_heal[name] = nil
ctf_classes.dont_heal[name] = true
elseif ctf_classes.dont_heal[name] then
ctf_classes.dont_heal[name] = nil
end
end)
minetest.register_on_leaveplayer(function(player)
dont_heal[player:get_player_name()] = nil
ctf_classes.dont_heal[player:get_player_name()] = nil
end)
local bandage_on_use = minetest.registered_items["ctf_bandages:bandage"].on_use
@ -95,7 +95,7 @@ minetest.override_item("ctf_bandages:bandage", {
local name = user:get_player_name()
if ctf.player(pname).team == ctf.player(name).team then
local nodename = minetest.get_node(object:get_pos()).name
if dont_heal[pname] or nodename:find("lava") or nodename:find("water") or nodename:find("trap") then
if ctf_classes.dont_heal[pname] or nodename:find("lava") or nodename:find("water") or nodename:find("trap") then
return -- Can't heal players in lava/water/spikes
end