2019-02-23 13:14:09 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
|
|
|
local math, nodecore, tonumber, tostring
|
|
|
|
= math, nodecore, tonumber, tostring
|
|
|
|
local math_ceil
|
|
|
|
= math.ceil
|
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
2019-02-24 13:54:58 -05:00
|
|
|
local function getphealth(player)
|
|
|
|
return player:get_hp()
|
2019-02-23 13:14:09 -05:00
|
|
|
+ tonumber(player:get_attribute("dhp") or "0")
|
2019-02-24 13:54:58 -05:00
|
|
|
end
|
|
|
|
nodecore.getphealth = getphealth
|
|
|
|
|
|
|
|
local function setphealth(player, hp)
|
|
|
|
if hp > 20 then hp = 20 end
|
|
|
|
if hp < 0 then hp = 0 end
|
|
|
|
local whole = math_ceil(hp)
|
|
|
|
local dhp = hp - whole
|
2019-02-23 13:14:09 -05:00
|
|
|
player:set_attribute("dhp", tostring(dhp))
|
|
|
|
return player:set_hp(whole)
|
|
|
|
end
|
2019-02-24 13:54:58 -05:00
|
|
|
nodecore.setphealth = setphealth
|
|
|
|
|
|
|
|
function nodecore.addphealth(player, hp)
|
|
|
|
return setphealth(player, getphealth(player) + hp)
|
|
|
|
end
|