From dec92749f95582c8661af30c91aff3153ca52f15 Mon Sep 17 00:00:00 2001 From: Pilcrow182 Date: Tue, 14 Apr 2015 18:22:22 -0500 Subject: [PATCH] Put aromr drops into a single loop, fix #22 --- 3d_armor/armor.lua | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/3d_armor/armor.lua b/3d_armor/armor.lua index c78e2af..8be009c 100644 --- a/3d_armor/armor.lua +++ b/3d_armor/armor.lua @@ -497,30 +497,28 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then local owner = meta:get_string("owner") local inv = meta:get_inventory() if name == owner then - for i, stack in ipairs(drop) do + for _,stack in ipairs(drop) do if inv:room_for_item("main", stack) then inv:add_item("main", stack) - table.remove(drop, i) + 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 - for _,stack in ipairs(drop) do - 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