forked from VoxeLibre/VoxeLibre
Clean up potion functions. Correct fault where it's possible to index a nil value.
This commit is contained in:
parent
834ce1f611
commit
d22805cecd
|
@ -19,8 +19,6 @@ minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
if is_invisible[player] and player:get_properties() then
|
if is_invisible[player] and player:get_properties() then
|
||||||
|
|
||||||
player = player or player:get_luaentity()
|
|
||||||
|
|
||||||
is_invisible[player].timer = is_invisible[player].timer + dtime
|
is_invisible[player].timer = is_invisible[player].timer + dtime
|
||||||
|
|
||||||
if player:get_pos() then mcl_potions._add_spawner(player, "#B0B0B0") end
|
if player:get_pos() then mcl_potions._add_spawner(player, "#B0B0B0") end
|
||||||
|
@ -53,15 +51,14 @@ minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
if entity and entity._cmi_is_mob then
|
if entity and entity._cmi_is_mob then
|
||||||
entity.health = math.max(entity.health - 1, 1)
|
entity.health = math.max(entity.health - 1, 1)
|
||||||
|
is_poisoned[player].hit_timer = 0
|
||||||
elseif is_player then
|
elseif is_player then
|
||||||
player:set_hp( math.max(player:get_hp() - 1, 1), { type = "punch", other = "poison"})
|
player:set_hp( math.max(player:get_hp() - 1, 1), { type = "punch", other = "poison"})
|
||||||
|
is_poisoned[player].hit_timer = 0
|
||||||
else -- if not player or mob then remove
|
else -- if not player or mob then remove
|
||||||
is_poisoned[player] = nil
|
is_poisoned[player] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
is_poisoned[player].hit_timer = 0
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_poisoned[player].timer >= is_poisoned[player].dur then
|
if is_poisoned[player].timer >= is_poisoned[player].dur then
|
||||||
|
@ -77,9 +74,8 @@ minetest.register_globalstep(function(dtime)
|
||||||
-- Check for regnerating players
|
-- Check for regnerating players
|
||||||
for player, vals in pairs(is_regenerating) do
|
for player, vals in pairs(is_regenerating) do
|
||||||
|
|
||||||
if is_regenerating[player] and player:get_properties() then
|
if is_regenerating[player] then
|
||||||
|
|
||||||
player = player or player:get_luaentity()
|
|
||||||
is_player = player:is_player()
|
is_player = player:is_player()
|
||||||
entity = player:get_luaentity()
|
entity = player:get_luaentity()
|
||||||
|
|
||||||
|
@ -92,14 +88,14 @@ minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
if is_player then
|
if is_player then
|
||||||
player:set_hp(math.min(player:get_properties().hp_max or 20, player:get_hp() + 1), { type = "set_hp", other = "regeneration" })
|
player:set_hp(math.min(player:get_properties().hp_max or 20, player:get_hp() + 1), { type = "set_hp", other = "regeneration" })
|
||||||
|
is_regenerating[player].heal_timer = 0
|
||||||
elseif entity and entity._cmi_is_mob then
|
elseif entity and entity._cmi_is_mob then
|
||||||
entity.health = math.min(entity.hp_max, entity.health + 1)
|
entity.health = math.min(entity.hp_max, entity.health + 1)
|
||||||
|
is_regenerating[player].heal_timer = 0
|
||||||
else -- stop regenerating if not a player or mob
|
else -- stop regenerating if not a player or mob
|
||||||
is_regenerating[player] = nil
|
is_regenerating[player] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
is_regenerating[player].heal_timer = 0
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_regenerating[player].timer >= is_regenerating[player].dur then
|
if is_regenerating[player].timer >= is_regenerating[player].dur then
|
||||||
|
@ -115,9 +111,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
-- Check for water breathing players
|
-- Check for water breathing players
|
||||||
for player, vals in pairs(is_water_breathing) do
|
for player, vals in pairs(is_water_breathing) do
|
||||||
|
|
||||||
if is_water_breathing[player] and player:get_properties() then
|
if is_water_breathing[player] and player:is_player() then
|
||||||
|
|
||||||
player = player or player:get_luaentity()
|
|
||||||
|
|
||||||
is_water_breathing[player].timer = is_water_breathing[player].timer + dtime
|
is_water_breathing[player].timer = is_water_breathing[player].timer + dtime
|
||||||
|
|
||||||
|
@ -131,7 +125,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
is_water_breathing[player] = nil
|
is_water_breathing[player] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif not player:get_properties() then
|
elseif not player:is_player() then
|
||||||
is_water_breathing[player] = nil
|
is_water_breathing[player] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue