Code style for #1890

iliekprogrammar 2021-11-12 02:28:27 +08:00
parent bca5033fb2
commit 0564121183
No known key found for this signature in database
GPG Key ID: 8E7B20514DBCFBFA

@ -134,10 +134,7 @@ minetest.register_on_player_hpchange(function(player, hp_change)
end end
end) end)
local food_tick_timers = {} -- one food_tick_timer per player, keys are the player-objects
local food_tick_timers = {} --one food_tick_timer per player, keys are the player-objects
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
for _,player in pairs(minetest.get_connected_players()) do for _,player in pairs(minetest.get_connected_players()) do
@ -150,22 +147,24 @@ minetest.register_globalstep(function(dtime)
if food_tick_timer > 4.0 then if food_tick_timer > 4.0 then
food_tick_timer = 0 food_tick_timer = 0
if food_level >= 18 then --slow regenration if food_level >= 18 then -- slow regenration
if player_health > 0 and player_health < 20 then if player_health > 0 and player_health < 20 then
player:set_hp(player_health+1) player:set_hp(player_health+1)
mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_REGEN) mcl_hunger.exhaust(player_name, mcl_hunger.EXHAUST_REGEN)
mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player)) mcl_hunger.update_exhaustion_hud(player, mcl_hunger.get_exhaustion(player))
end end
elseif food_level == 0 then --starvation elseif food_level == 0 then -- starvation
local maximum_starvation = 1 --the amount of health at which a player will stop to get harmed by starvation (10 for Easy, 1 for Normal, 0 for Hard) -- the amount of health at which a player will stop to get
-- harmed by starvation (10 for Easy, 1 for Normal, 0 for Hard)
local maximum_starvation = 1
-- TODO: implement Minecraft-like difficulty modes and the update maximumStarvation here -- TODO: implement Minecraft-like difficulty modes and the update maximumStarvation here
if player_health > maximum_starvation then if player_health > maximum_starvation then
mcl_util.deal_damage(player, 1, {type = "starve"}) mcl_util.deal_damage(player, 1, {type = "starve"})
end end
end end
elseif food_tick_timer > 0.5 and food_level == 20 and food_saturation_level >= 6 then --fast regeneration elseif food_tick_timer > 0.5 and food_level == 20 and food_saturation_level >= 6 then -- fast regeneration
if player_health > 0 and player_health < 20 then if player_health > 0 and player_health < 20 then
food_tick_timer = 0 food_tick_timer = 0
player:set_hp(player_health+1) player:set_hp(player_health+1)
@ -174,7 +173,7 @@ minetest.register_globalstep(function(dtime)
end end
end end
food_tick_timers[player] = food_tick_timer --update food_tick_timer table food_tick_timers[player] = food_tick_timer -- update food_tick_timer table
end end
end) end)