Aaron Suen af1f808c68 Fix player health FX auto-scaling.
Guarantee 2 usable slots no matter how many different
injury effects accumulate.

Filled slots will be shared among different damage types
roughly proportionally.
2019-10-13 12:57:57 -04:00

27 lines
775 B
Lua

-- LUALOCALS < ---------------------------------------------------------
local minetest, nodecore
= minetest, nodecore
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local hand = minetest.registered_items[""]
local injured = modname .. ":injured"
minetest.register_craftitem(injured, {
description = "Injury",
stack_max = 1,
inventory_image = modname .. "_injured.png",
wield_image = hand.wield_image,
wield_scale = hand.wield_scale,
on_drop = function(stack) return stack end,
on_place = function(stack) return stack end,
virtual_item = true
})
nodecore.register_healthfx({
item = injured,
getqty = function(player)
return 1 - nodecore.getphealth(player) / 20
end
})