Ensure minimum value of 0

master
Wuzzy 2016-11-10 15:57:51 +01:00
parent d4bc5dc190
commit c4ddb7b344
1 changed files with 3 additions and 3 deletions

View File

@ -84,7 +84,7 @@ if(minetest.setting_getbool("enable_damage") == true) then
minetest.chat_send_player(name, S("This is not a number."))
return
end
hp = math.floor(hp+0.5) -- round the number
hp = math.max(0, math.floor(hp+0.5)) -- round the number, ensure minimum value of 0
player:set_hp(tonumber(hp))
end,
})
@ -107,7 +107,7 @@ if(minetest.setting_getbool("enable_damage") == true) then
return
end
local hp = tonumber(hearts) * 2
hp = math.floor(hp+0.5) -- round the number
hp = math.max(0, math.floor(hp+0.5)) -- round the number, ensure minimum value of 0
player:set_hp(hp)
end,
})
@ -129,7 +129,7 @@ if(minetest.setting_getbool("enable_damage") == true) then
minetest.chat_send_player(name, S("This is not a number."))
return
end
local bp = tonumber(breath)
local bp = math.max(0, tonumber(breath)) -- ensure minimum value of 0
player:set_breath(bp)
end,
})