Ensure minimum value of 0
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."))
|
minetest.chat_send_player(name, S("This is not a number."))
|
||||||
return
|
return
|
||||||
end
|
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))
|
player:set_hp(tonumber(hp))
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -107,7 +107,7 @@ if(minetest.setting_getbool("enable_damage") == true) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local hp = tonumber(hearts) * 2
|
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)
|
player:set_hp(hp)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -129,7 +129,7 @@ if(minetest.setting_getbool("enable_damage") == true) then
|
||||||
minetest.chat_send_player(name, S("This is not a number."))
|
minetest.chat_send_player(name, S("This is not a number."))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local bp = tonumber(breath)
|
local bp = math.max(0, tonumber(breath)) -- ensure minimum value of 0
|
||||||
player:set_breath(bp)
|
player:set_breath(bp)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue