mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2024-11-29 23:43:42 +01:00
drop armor if no bones node is found
This commit is contained in:
parent
b3f755f7d7
commit
d2f32beebb
@ -464,6 +464,21 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
if ARMOR_DROP == true or ARMOR_DESTROY == true then
|
if ARMOR_DROP == true or ARMOR_DESTROY == true then
|
||||||
|
armor.drop_armor = function(pos, stack)
|
||||||
|
local obj = minetest.add_item(pos, stack)
|
||||||
|
if obj then
|
||||||
|
local x = math.random(1, 5)
|
||||||
|
if math.random(1,2) == 1 then
|
||||||
|
x = -x
|
||||||
|
end
|
||||||
|
local z = math.random(1, 5)
|
||||||
|
if math.random(1,2) == 1 then
|
||||||
|
z = -z
|
||||||
|
end
|
||||||
|
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
minetest.register_on_dieplayer(function(player)
|
||||||
local name, player_inv, armor_inv, pos = armor:get_valid_player(player, "[on_dieplayer]")
|
local name, player_inv, armor_inv, pos = armor:get_valid_player(player, "[on_dieplayer]")
|
||||||
if not name then
|
if not name then
|
||||||
@ -488,37 +503,26 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then
|
|||||||
armor:update_inventory(player)
|
armor:update_inventory(player)
|
||||||
end
|
end
|
||||||
if ARMOR_DESTROY == false then
|
if ARMOR_DESTROY == false then
|
||||||
if minetest.get_modpath("bones") then
|
minetest.after(ARMOR_BONES_DELAY, function()
|
||||||
minetest.after(ARMOR_BONES_DELAY, function()
|
pos = vector.round(pos)
|
||||||
pos = vector.round(pos)
|
local node = minetest.get_node(pos)
|
||||||
local node = minetest.get_node(pos)
|
if node and node.name == "bones:bones" then
|
||||||
if node.name == "bones:bones" then
|
local meta = minetest.get_meta(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local owner = meta:get_string("owner")
|
||||||
local owner = meta:get_string("owner")
|
local inv = meta:get_inventory()
|
||||||
local inv = meta:get_inventory()
|
for _,stack in ipairs(drop) do
|
||||||
if name == owner then
|
if name == owner and inv:room_for_item("main", stack) then
|
||||||
for _,stack in ipairs(drop) do
|
inv:add_item("main", stack)
|
||||||
if inv:room_for_item("main", stack) then
|
else
|
||||||
inv:add_item("main", stack)
|
armor.drop_armor(pos, stack)
|
||||||
else
|
|
||||||
local obj = minetest.add_item(pos, stack)
|
|
||||||
if obj then
|
|
||||||
local x = math.random(1, 5)
|
|
||||||
if math.random(1,2) == 1 then
|
|
||||||
x = -x
|
|
||||||
end
|
|
||||||
local z = math.random(1, 5)
|
|
||||||
if math.random(1,2) == 1 then
|
|
||||||
z = -z
|
|
||||||
end
|
|
||||||
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
else
|
||||||
end
|
for _,stack in ipairs(drop) do
|
||||||
|
armor.drop_armor(pos, stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user