diff options
author | Alexander Ried <ried@mytum.de> | 2020-06-22 06:41:30 +0000 |
---|---|---|
committer | groxxda <ried@mytum.de> | 2020-06-30 10:11:22 +0000 |
commit | c79e68a80c2aec939143af99b15173c05d067d2b (patch) | |
tree | ecba5c01de2135a46e97b2b8dfe968ab176f3007 /autoplace_tubes.lua | |
parent | 9338c109a6aa5c8c160b18f2ebd7da773bfb7a66 (diff) | |
download | pipeworks-c79e68a80c2aec939143af99b15173c05d067d2b.tar pipeworks-c79e68a80c2aec939143af99b15173c05d067d2b.tar.gz pipeworks-c79e68a80c2aec939143af99b15173c05d067d2b.tar.bz2 pipeworks-c79e68a80c2aec939143af99b15173c05d067d2b.tar.xz pipeworks-c79e68a80c2aec939143af99b15173c05d067d2b.zip |
Consider connect_sides for item transport
Previously connect_sides was only used to choose the correct visual
model, but not during item transport. This allowed items to exit tubes
in directions without a visual connection and enter objects from sides
that should not be connectable according to connect_sides.
For example an item could enter a chest from the front, if a tube passed
there.
This change saves the connect_sides in the meta table of the object
whenever the visual representation is updated. When nothing is cached
yet, it uses the old behavior. That way it does not break existing
builds.
Diffstat (limited to 'autoplace_tubes.lua')
-rw-r--r-- | autoplace_tubes.lua | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/autoplace_tubes.lua b/autoplace_tubes.lua index 40a041f..51ee383 100644 --- a/autoplace_tubes.lua +++ b/autoplace_tubes.lua @@ -53,27 +53,28 @@ local function tube_autoroute(pos) } -- xm = 1, xp = 2, ym = 3, yp = 4, zm = 5, zp = 6 - local positions = {} - local nodes = {} + local adjlist = {} -- this will be used in item_transport + for i, adj in ipairs(adjustments) do - positions[i] = vector.add(pos, adj) - nodes[i] = minetest.get_node(positions[i]) - end + local position = vector.add(pos, adj) + local node = minetest.get_node(position) - for i, node in ipairs(nodes) do local idef = minetest.registered_nodes[node.name] -- handle the tubes themselves if is_tube(node.name) then active[i] = 1 + table.insert(adjlist, adj) -- handle new style connectors elseif idef and idef.tube and idef.tube.connect_sides then - local dir = adjustments[i] - if idef.tube.connect_sides[nodeside(node, vector.multiply(dir, -1))] then + if idef.tube.connect_sides[nodeside(node, vector.multiply(adj, -1))] then active[i] = 1 + table.insert(adjlist, adj) end end end + minetest.get_meta(pos):set_string("adjlist", minetest.serialize(adjlist)) + -- all sides checked, now figure which tube to use. local nodedef = minetest.registered_nodes[nctr.name] |