Code cleanup

This commit is contained in:
Brandon 2020-07-25 20:59:26 -04:00
parent d22805cecd
commit 9dce5581be

View file

@ -17,8 +17,6 @@ minetest.register_globalstep(function(dtime)
-- Check for invisible players -- Check for invisible players
for player, vals in pairs(is_invisible) do for player, vals in pairs(is_invisible) do
if is_invisible[player] and player:get_properties() then
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
@ -28,17 +26,11 @@ minetest.register_globalstep(function(dtime)
is_invisible[player] = nil is_invisible[player] = nil
end end
elseif not player:get_properties() then
is_invisible[player] = nil
end
end end
-- Check for poisoned players -- Check for poisoned players
for player, vals in pairs(is_poisoned) do for player, vals in pairs(is_poisoned) do
if is_poisoned[player] and player:get_properties() then
is_player = player:is_player() is_player = player:is_player()
entity = player:get_luaentity() entity = player:get_luaentity()
@ -65,17 +57,11 @@ minetest.register_globalstep(function(dtime)
is_poisoned[player] = nil is_poisoned[player] = nil
end end
elseif not player:get_properties() then
is_poisoned[player] = nil
end
end end
-- 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] then
is_player = player:is_player() is_player = player:is_player()
entity = player:get_luaentity() entity = player:get_luaentity()
@ -102,16 +88,12 @@ minetest.register_globalstep(function(dtime)
is_regenerating[player] = nil is_regenerating[player] = nil
end end
elseif not player:get_properties() then
is_regenerating[player] = nil
end
end end
-- 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:is_player() then if player:is_player() then
is_water_breathing[player].timer = is_water_breathing[player].timer + dtime is_water_breathing[player].timer = is_water_breathing[player].timer + dtime
@ -125,7 +107,7 @@ minetest.register_globalstep(function(dtime)
is_water_breathing[player] = nil is_water_breathing[player] = nil
end end
elseif not player:is_player() then else
is_water_breathing[player] = nil is_water_breathing[player] = nil
end end
@ -134,9 +116,7 @@ minetest.register_globalstep(function(dtime)
-- Check for leaping players -- Check for leaping players
for player, vals in pairs(is_leaping) do for player, vals in pairs(is_leaping) do
if is_leaping[player] and player:get_properties() then if player:is_player() then
player = player or player:get_luaentity()
is_leaping[player].timer = is_leaping[player].timer + dtime is_leaping[player].timer = is_leaping[player].timer + dtime
@ -147,7 +127,7 @@ minetest.register_globalstep(function(dtime)
is_leaping[player] = nil is_leaping[player] = nil
end end
elseif not player:get_properties() then else
is_leaping[player] = nil is_leaping[player] = nil
end end
@ -156,9 +136,7 @@ minetest.register_globalstep(function(dtime)
-- Check for swift players -- Check for swift players
for player, vals in pairs(is_swift) do for player, vals in pairs(is_swift) do
if is_swift[player] and player:get_properties() then if player:is_player() then
player = player or player:get_luaentity()
is_swift[player].timer = is_swift[player].timer + dtime is_swift[player].timer = is_swift[player].timer + dtime
@ -169,7 +147,7 @@ minetest.register_globalstep(function(dtime)
is_swift[player] = nil is_swift[player] = nil
end end
elseif not player:get_properties() then else
is_swift[player] = nil is_swift[player] = nil
end end
@ -178,9 +156,7 @@ minetest.register_globalstep(function(dtime)
-- Check for Night Vision equipped players -- Check for Night Vision equipped players
for player, vals in pairs(is_cat) do for player, vals in pairs(is_cat) do
if is_cat[player] and player:get_properties() then if player:is_player() then
player = player or player:get_luaentity()
is_cat[player].timer = is_cat[player].timer + dtime is_cat[player].timer = is_cat[player].timer + dtime
@ -194,7 +170,7 @@ minetest.register_globalstep(function(dtime)
is_cat[player] = nil is_cat[player] = nil
end end
elseif not player:get_properties() then else
is_cat[player] = nil is_cat[player] = nil
end end
@ -203,7 +179,7 @@ minetest.register_globalstep(function(dtime)
-- Check for Fire Proof players -- Check for Fire Proof players
for player, vals in pairs(is_fire_proof) do for player, vals in pairs(is_fire_proof) do
if is_fire_proof[player] and player:get_properties() then if player:is_player() then
player = player or player:get_luaentity() player = player or player:get_luaentity()
@ -215,7 +191,7 @@ minetest.register_globalstep(function(dtime)
is_fire_proof[player] = nil is_fire_proof[player] = nil
end end
elseif not player:get_properties() then else
is_fire_proof[player] = nil is_fire_proof[player] = nil
end end
@ -224,9 +200,7 @@ minetest.register_globalstep(function(dtime)
-- Check for Weak players -- Check for Weak players
for player, vals in pairs(is_weak) do for player, vals in pairs(is_weak) do
if is_weak[player] and player:get_properties() then if player:is_player() then
player = player or player:get_luaentity()
is_weak[player].timer = is_weak[player].timer + dtime is_weak[player].timer = is_weak[player].timer + dtime
@ -236,7 +210,7 @@ minetest.register_globalstep(function(dtime)
is_weak[player] = nil is_weak[player] = nil
end end
elseif not player:get_properties() then else
is_weak[player] = nil is_weak[player] = nil
end end
@ -245,9 +219,7 @@ minetest.register_globalstep(function(dtime)
-- Check for Strong players -- Check for Strong players
for player, vals in pairs(is_strong) do for player, vals in pairs(is_strong) do
if is_strong[player] and player:get_properties() then if player:is_player() then
player = player or player:get_luaentity()
is_strong[player].timer = is_strong[player].timer + dtime is_strong[player].timer = is_strong[player].timer + dtime
@ -257,7 +229,7 @@ minetest.register_globalstep(function(dtime)
is_strong[player] = nil is_strong[player] = nil
end end
elseif not player:get_properties() then else
is_strong[player] = nil is_strong[player] = nil
end end
@ -301,8 +273,6 @@ end, true)
function mcl_potions._reset_player_effects(player) function mcl_potions._reset_player_effects(player)
player = player or player:get_luaentity()
if is_invisible[player] then if is_invisible[player] then
mcl_potions.make_invisible(player, false) mcl_potions.make_invisible(player, false)
is_invisible[player] = nil is_invisible[player] = nil