1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2024-12-26 19:00:24 +01:00

Fix item transport code

This commit is contained in:
Novatux 2013-12-21 10:16:58 +01:00
parent e5344edf98
commit 75db2c5307

View File

@ -123,7 +123,6 @@ minetest.register_node("pipeworks:filter", {
local frompos = {x=pos.x - dir.x, y=pos.y - dir.y, z=pos.z - dir.z} local frompos = {x=pos.x - dir.x, y=pos.y - dir.y, z=pos.z - dir.z}
local fromnode=minetest.get_node(frompos) local fromnode=minetest.get_node(frompos)
if not fromnode then return end if not fromnode then return end
local frominv
local idef = minetest.registered_nodes[fromnode.name] local idef = minetest.registered_nodes[fromnode.name]
-- assert(idef) -- assert(idef)
local tube = idef.tube local tube = idef.tube
@ -133,8 +132,9 @@ minetest.register_node("pipeworks:filter", {
local frommeta = minetest.get_meta(frompos) local frommeta = minetest.get_meta(frompos)
local frominvname = tube.input_inventory local frominvname = tube.input_inventory
local frominv = frommeta:get_inventory() local frominv = frommeta:get_inventory()
local sname
for _,filter in ipairs(inv:get_list("main")) do for _,filter in ipairs(inv:get_list("main")) do
local sname=filter:get_name() sname = filter:get_name()
if sname ~= "" then if sname ~= "" then
-- XXX: that's a lot of parameters -- XXX: that's a lot of parameters
grabAndFire(frominv, frominvname, frompos, fromnode, sname, tube, idef, dir) grabAndFire(frominv, frominvname, frompos, fromnode, sname, tube, idef, dir)
@ -190,7 +190,6 @@ minetest.register_node("pipeworks:mese_filter", {
local dir = facedir_to_right_dir(node.param2) local dir = facedir_to_right_dir(node.param2)
local frompos = {x=pos.x - dir.x, y=pos.y - dir.y, z=pos.z - dir.z} local frompos = {x=pos.x - dir.x, y=pos.y - dir.y, z=pos.z - dir.z}
local fromnode=minetest.get_node(frompos) local fromnode=minetest.get_node(frompos)
local frominv
local idef = minetest.registered_nodes[fromnode.name] local idef = minetest.registered_nodes[fromnode.name]
-- assert(idef) -- assert(idef)
local tube = idef.tube local tube = idef.tube
@ -200,8 +199,9 @@ minetest.register_node("pipeworks:mese_filter", {
local frommeta = minetest.get_meta(frompos) local frommeta = minetest.get_meta(frompos)
local frominvname = minetest.registered_nodes[fromnode.name].tube.input_inventory local frominvname = minetest.registered_nodes[fromnode.name].tube.input_inventory
local frominv = frommeta:get_inventory() local frominv = frommeta:get_inventory()
local sname
for _,filter in ipairs(inv:get_list("main")) do for _,filter in ipairs(inv:get_list("main")) do
local sname=filter:get_name() sname = filter:get_name()
if sname ~= "" then if sname ~= "" then
grabAndFire(frominv, frominvname, frompos, fromnode, sname, tube, idef, dir, true) grabAndFire(frominv, frominvname, frompos, fromnode, sname, tube, idef, dir, true)
end end
@ -235,11 +235,6 @@ local function go_next(pos,velocity,stack)
local tubes = {} local tubes = {}
local cnode = minetest.get_node(pos) local cnode = minetest.get_node(pos)
local cmeta = minetest.get_meta(pos) local cmeta = minetest.get_meta(pos)
local node
local meta
local tubelike
local tube_receiver
local len = 1
local n local n
local can_go local can_go
local speed = math.abs(velocity.x + velocity.y + velocity.z) local speed = math.abs(velocity.x + velocity.y + velocity.z)
@ -253,7 +248,7 @@ local function go_next(pos,velocity,stack)
end end
vel.speed=speed vel.speed=speed
if minetest.registered_nodes[cnode.name] and minetest.registered_nodes[cnode.name].tube and minetest.registered_nodes[cnode.name].tube.can_go then 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,node,vel,stack) can_go = minetest.registered_nodes[cnode.name].tube.can_go(pos, cnode, vel, stack)
else else
can_go = pipeworks.notvel(adjlist, vel) can_go = pipeworks.notvel(adjlist, vel)
end end
@ -284,18 +279,18 @@ local function go_next(pos,velocity,stack)
if tubes[1] == nil then if tubes[1] == nil then
return 0 return 0
else else
n = (meta:get_int("tubedir")%(#tubes)) + 1 n = (cmeta:get_int("tubedir")%(#tubes)) + 1
if pipeworks.enable_cyclic_mode then if pipeworks.enable_cyclic_mode then
meta:set_int("tubedir",n) cmeta:set_int("tubedir",n)
end end
velocity.x = tubes[n].vect.x*vel.speed velocity.x = tubes[n].vect.x*vel.speed
velocity.y = tubes[n].vect.y*vel.speed velocity.y = tubes[n].vect.y*vel.speed
velocity.z = tubes[n].vect.z*vel.speed velocity.z = tubes[n].vect.z*vel.speed
end end
else else
n = (meta:get_int("tubedir")%(#chests))+1 n = (cmeta:get_int("tubedir")%(#chests))+1
if pipeworks.enable_cyclic_mode then if pipeworks.enable_cyclic_mode then
meta:set_int("tubedir",n) cmeta:set_int("tubedir",n)
end end
velocity.x = chests[n].vect.x*speed velocity.x = chests[n].vect.x*speed
velocity.y = chests[n].vect.y*speed velocity.y = chests[n].vect.y*speed