summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-12-19 22:53:18 +0000
committerthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-12-19 22:53:18 +0000
commitfb91ba53f1af1d5d618f7610cdd04e3895ebd6c6 (patch)
tree5a5d61461d12e606a23ba4936b4625aaf1cc727a
parent97522b6a244a34be9e384c151618ab8db74aea46 (diff)
downloadpipeworks-fb91ba53f1af1d5d618f7610cdd04e3895ebd6c6.tar
pipeworks-fb91ba53f1af1d5d618f7610cdd04e3895ebd6c6.tar.gz
pipeworks-fb91ba53f1af1d5d618f7610cdd04e3895ebd6c6.tar.bz2
pipeworks-fb91ba53f1af1d5d618f7610cdd04e3895ebd6c6.tar.xz
pipeworks-fb91ba53f1af1d5d618f7610cdd04e3895ebd6c6.zip
item_transport.lua: read cycle direction at start of go_next() in preparation for refactoring
-rw-r--r--item_transport.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/item_transport.lua b/item_transport.lua
index d0b0e63..72f6d7d 100644
--- a/item_transport.lua
+++ b/item_transport.lua
@@ -100,6 +100,11 @@ local function go_next(pos, velocity, stack, owner)
vel.speed = speed
crunch_tube(pos, cnode, cmeta)
+ -- cycling of outputs:
+ -- an integer counter is kept in each pipe's metadata,
+ -- which allows tracking which output was previously chosen.
+ -- note reliance on get_int returning 0 for uninitialised.
+ local cycledir = cmeta:get_int("tubedir")
if minetest.registered_nodes[cnode.name] and minetest.registered_nodes[cnode.name].tube and minetest.registered_nodes[cnode.name].tube.can_go then
can_go = minetest.registered_nodes[cnode.name].tube.can_go(pos, cnode, vel, stack)
@@ -132,7 +137,9 @@ local function go_next(pos, velocity, stack, owner)
return false, nil, nil
end
- local n = (cmeta:get_int("tubedir") % (#next_positions)) + 1
+ local n = (cycledir % (#next_positions)) + 1
+ -- if not using output cycling,
+ -- don't update the field so it stays the same for the next item.
if pipeworks.enable_cyclic_mode then
cmeta:set_int("tubedir", n)
end