minetest.register_craftitem ("coderblocks:bandage", { description = "Bandage" , inventory_image = "coderblocks_bandage.png" , on_use = function (itemstack, player, pointed_thing) -- Percentage of total HP to be healed local heal_percent = 0.75 if pointed_thing.type ~= "object" then return end local object = pointed_thing.ref if not object:is_player() then return end local pname = object:get_player_name() local name = player:get_player_name() local hp = object:get_hp() local limit = heal_percent * object:get_properties().hp_max if hp > 0 and hp < limit then hp = hp + math.random (3, 4) if hp > limit then hp = limit end object:set_hp (hp) itemstack:take_item() minetest.chat_send_player (pname, minetest.colorize ("#C1FF44", name .. " has healed you!")) return itemstack else minetest.chat_send_player (name, pname .. " has " .. hp .. " HP. You can't heal them.") end end , })