capturetheflag/mods/ctf/ctf_bandages/init.lua
MinetestSam 0829d4c700 ctf_bandages: Show coloured alert to target when being healed (#436)
Also increase the spawn rate of bandages.

Co-Authored-By: ANAND <ClobberXD@gmail.com>
2019-07-13 06:48:48 +05:30

36 lines
1.1 KiB
Lua

--Inspired from Andrey's bandages mod
local healing_limit = 15
minetest.register_craftitem("ctf_bandages:bandage", {
description = "Bandage, heals teammates for 3-4 HP until HP is equal to "..healing_limit,
inventory_image = "ctf_bandages_bandage.png",
on_use = function(itemstack, player, pointed_thing)
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()
if ctf.player(pname).team == ctf.player(name).team then
local hp = object:get_hp()
if hp > 0 and hp < healing_limit then
hp = hp + math.random(3,4)
if hp > healing_limit then
hp = healing_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
else
minetest.chat_send_player(name, pname.." isn't in your team!")
end
end,
})