summaryrefslogtreecommitdiff
path: root/item_transport.lua
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2013-01-19 19:11:28 +0100
committerNovatux <nathanael.courant@laposte.net>2013-01-19 19:11:28 +0100
commit5edb7a61a3b7e9ab19146b6e76592b86bb79f5f2 (patch)
treec892ea3392c8e2b6a2f568f17f5a456d307ad429 /item_transport.lua
parent23bf19f480419283ea6e7b77a6dca8c19aeb8829 (diff)
downloadpipeworks-5edb7a61a3b7e9ab19146b6e76592b86bb79f5f2.tar
pipeworks-5edb7a61a3b7e9ab19146b6e76592b86bb79f5f2.tar.gz
pipeworks-5edb7a61a3b7e9ab19146b6e76592b86bb79f5f2.tar.bz2
pipeworks-5edb7a61a3b7e9ab19146b6e76592b86bb79f5f2.tar.xz
pipeworks-5edb7a61a3b7e9ab19146b6e76592b86bb79f5f2.zip
Changed mese tubes: you can now choose if items should not go in a direction.
Diffstat (limited to 'item_transport.lua')
-rw-r--r--item_transport.lua58
1 files changed, 32 insertions, 26 deletions
diff --git a/item_transport.lua b/item_transport.lua
index bed8f31..7cc2853 100644
--- a/item_transport.lua
+++ b/item_transport.lua
@@ -273,6 +273,14 @@ end
adjlist={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=1,y=0,z=0},{x=-1,y=0,z=0}}
+function notvel(tbl,vel)
+ tbl2={}
+ for _,val in ipairs(tbl) do
+ if val.x~=-vel.x or val.y~=-vel.y or val.z~=-vel.z then table.insert(tbl2,val) end
+ end
+ return tbl2
+end
+
function go_next(pos,velocity,stack)
--print(dump(pos))
local chests={}
@@ -299,39 +307,37 @@ function go_next(pos,velocity,stack)
if 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,node,vel,stack)
else
- can_go=adjlist
+ can_go=notvel(adjlist,vel)
end
for _,vect in ipairs(can_go) do
- if vect.x~=-vel.x or vect.y~=-vel.y or vect.z~=-vel.z then
- npos=addVect(pos,vect)
- node=minetest.env:get_node(npos)
- tube_receiver=minetest.get_item_group(node.name,"tubedevice_receiver")
- --tubelike=minetest.get_item_group(node.name,"tubelike")
- meta=minetest.env:get_meta(npos)
- tubelike=meta:get_int("tubelike")
- if tube_receiver==1 then
- if minetest.registered_nodes[node.name].tube and
- minetest.registered_nodes[node.name].tube.can_insert and
- minetest.registered_nodes[node.name].tube.can_insert(npos,node,stack,vect) then
- local i=1
- repeat
- if chests[i]==nil then break end
- i=i+1
- until false
- chests[i]={}
- chests[i].pos=npos
- chests[i].vect=vect
- end
- elseif tubelike==1 then
+ npos=addVect(pos,vect)
+ node=minetest.env:get_node(npos)
+ tube_receiver=minetest.get_item_group(node.name,"tubedevice_receiver")
+ --tubelike=minetest.get_item_group(node.name,"tubelike")
+ meta=minetest.env:get_meta(npos)
+ tubelike=meta:get_int("tubelike")
+ if tube_receiver==1 then
+ if minetest.registered_nodes[node.name].tube and
+ minetest.registered_nodes[node.name].tube.can_insert and
+ minetest.registered_nodes[node.name].tube.can_insert(npos,node,stack,vect) then
local i=1
repeat
- if tubes[i]==nil then break end
+ if chests[i]==nil then break end
i=i+1
until false
- tubes[i]={}
- tubes[i].pos=npos
- tubes[i].vect=vect
+ chests[i]={}
+ chests[i].pos=npos
+ chests[i].vect=vect
end
+ elseif tubelike==1 then
+ local i=1
+ repeat
+ if tubes[i]==nil then break end
+ i=i+1
+ until false
+ tubes[i]={}
+ tubes[i].pos=npos
+ tubes[i].vect=vect
end
end
if chests[1]==nil then--no chests found