Fix bug in mesecon.mergetable that caused false rules

This commit is contained in:
Jeija 2014-11-22 16:00:49 +01:00
parent 5be179bf11
commit 29dc50057c
2 changed files with 10 additions and 11 deletions

@ -194,13 +194,14 @@ function mesecon.cmpAny(t1, t2)
return true return true
end end
-- does not overwrite values -- does not overwrite values; number keys (ipairs) are appended, not overwritten
mesecon.mergetable = function(source, dest) mesecon.mergetable = function(source, dest)
for k, v in pairs(source) do for k, v in pairs(source) do
dest[k] = dest[k] or v dest[k] = dest[k] or v
end end
for i, v in ipairs(source) do for i, v in ipairs(source) do
dest[i] = dest[i] or v table.insert(dest, v)
end end
end end

@ -91,8 +91,7 @@ function mesecon.receiver_get_pos_from_rcpt(pos, param2)
elseif param2 == 0 then elseif param2 == 0 then
rules = mesecon.rotate_rules_right(rules) rules = mesecon.rotate_rules_right(rules)
end end
np = { local np = { x = pos.x + rules[1].x,
x = pos.x + rules[1].x,
y = pos.y + rules[1].y, y = pos.y + rules[1].y,
z = pos.z + rules[1].z} z = pos.z + rules[1].z}
return np return np
@ -141,14 +140,13 @@ end)
minetest.register_on_placenode(function (pos, node) minetest.register_on_placenode(function (pos, node)
if string.find(node.name, "mesecons:wire_") ~=nil then if string.find(node.name, "mesecons:wire_") ~=nil then
rules = { {x = 2, y = 0, z = 0}, local rules = { {x = 2, y = 0, z = 0},
{x =-2, y = 0, z = 0}, {x =-2, y = 0, z = 0},
{x = 0, y = 0, z = 2}, {x = 0, y = 0, z = 2},
{x = 0, y = 0, z =-2}} {x = 0, y = 0, z =-2}}
local i = 1 local i = 1
while rules[i] ~= nil do while rules[i] ~= nil do
np = { local np = { x = pos.x + rules[i].x,
x = pos.x + rules[i].x,
y = pos.y + rules[i].y, y = pos.y + rules[i].y,
z = pos.z + rules[i].z} z = pos.z + rules[i].z}
if minetest.get_item_group(minetest.get_node(np).name, "mesecon_needs_receiver") == 1 then if minetest.get_item_group(minetest.get_node(np).name, "mesecon_needs_receiver") == 1 then