Ensure minimum value of 0
This commit is contained in:
parent
d4bc5dc190
commit
c4ddb7b344
6
init.lua
6
init.lua
@ -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,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user