Working on the special weapons
This commit is contained in:
parent
fd996103bb
commit
2ff548dd9f
@ -778,33 +778,50 @@ minetest.register_tool("nssm:axe_of_pride", {
|
||||
on_drop = function(itemstack, dropper, pos)
|
||||
local objects = minetest.env:get_objects_inside_radius(pos, 10)
|
||||
local flag = 0
|
||||
local meta = minetest.get_meta({x=0,y=0,z=0})
|
||||
|
||||
for _,obj in ipairs(objects) do
|
||||
local timer = meta:get_string("axe_of_pride_"..obj:get_player_name())
|
||||
minetest.chat_send_all(timer)
|
||||
if timer then
|
||||
if flag == 0 then
|
||||
|
||||
--timer = tonumber(timer)
|
||||
minetest.chat_send_all("Attenzione")
|
||||
|
||||
local tim = os.time() - timer
|
||||
if tim < 30 then
|
||||
minetest.chat_send_player(dropper:get_player_name(),"Too soon. Wait for "..30-tim.." seconds")
|
||||
local pname = dropper:get_player_name()
|
||||
local player_inv = minetest.get_inventory({type='player', name = pname})
|
||||
|
||||
if player_inv:is_empty('main') then
|
||||
--minetest.chat_send_all("Inventory empty")
|
||||
else
|
||||
local found = 0
|
||||
for i = 1,32 do
|
||||
--minetest.chat_send_all("Inventory is not empty")
|
||||
local items = player_inv:get_stack('main', i)
|
||||
local n = items:get_name()
|
||||
if n == "nssm:energy_globe" then
|
||||
if found == 0 then
|
||||
found = 1
|
||||
items:take_item()
|
||||
player_inv:set_stack('main', i, items)
|
||||
end
|
||||
end
|
||||
end
|
||||
if found == 0 then
|
||||
minetest.chat_send_player(pname, "You haven't got any Energy Globe!")
|
||||
return
|
||||
end
|
||||
end
|
||||
meta:set_string("axe_of_pride_"..dropper:get_player_name(), tostring(os.time()))
|
||||
else
|
||||
if (obj:is_player()) then
|
||||
--minetest.chat_send_all("Giocatore")
|
||||
if (obj:get_player_name()~=dropper:get_player_name()) then
|
||||
obj:set_hp(obj:get_hp()-10)
|
||||
dropper:set_hp(dropper:get_hp()+10)
|
||||
flag = 1
|
||||
end
|
||||
else
|
||||
if (obj:get_luaentity().health) then
|
||||
--minetest.chat_send_all("Entity")
|
||||
obj:get_luaentity().health = obj:get_luaentity().health -10
|
||||
dropper:set_hp(dropper:get_hp()+10)
|
||||
flag = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user