Allow setting dont_heal from other mods
This commit is contained in:
parent
8d55487a77
commit
0e79443fb5
1 changed files with 6 additions and 6 deletions
|
@ -64,19 +64,19 @@ minetest.register_globalstep(function(delta)
|
||||||
regen_update()
|
regen_update()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local dont_heal = {}
|
ctf_classes.dont_heal = {}
|
||||||
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
if reason.type == "drown" or reason.type == "node_damage" then
|
if reason.type == "drown" or reason.type == "node_damage" then
|
||||||
dont_heal[name] = true
|
ctf_classes.dont_heal[name] = true
|
||||||
elseif dont_heal[name] then
|
elseif ctf_classes.dont_heal[name] then
|
||||||
dont_heal[name] = nil
|
ctf_classes.dont_heal[name] = nil
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
dont_heal[player:get_player_name()] = nil
|
ctf_classes.dont_heal[player:get_player_name()] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local bandage_on_use = minetest.registered_items["ctf_bandages:bandage"].on_use
|
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()
|
local name = user:get_player_name()
|
||||||
if ctf.player(pname).team == ctf.player(name).team then
|
if ctf.player(pname).team == ctf.player(name).team then
|
||||||
local nodename = minetest.get_node(object:get_pos()).name
|
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
|
return -- Can't heal players in lava/water/spikes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue