summaryrefslogtreecommitdiff
path: root/teleport_tube.lua
diff options
context:
space:
mode:
authorVanessaE <vanessaezekowitz@gmail.com>2013-02-03 08:53:35 -0800
committerVanessaE <vanessaezekowitz@gmail.com>2013-02-03 08:53:35 -0800
commit8513f4a8813a36fce61e306621fa333510818fbc (patch)
tree6af16a7e9b079e055b41f8218882167b0f5626e5 /teleport_tube.lua
parent29671d5af6502fe1b31c5d06d282884766546178 (diff)
parent660feea1479a67144b0363086ca6fbdc78785f36 (diff)
downloadpipeworks-8513f4a8813a36fce61e306621fa333510818fbc.tar
pipeworks-8513f4a8813a36fce61e306621fa333510818fbc.tar.gz
pipeworks-8513f4a8813a36fce61e306621fa333510818fbc.tar.bz2
pipeworks-8513f4a8813a36fce61e306621fa333510818fbc.tar.xz
pipeworks-8513f4a8813a36fce61e306621fa333510818fbc.zip
Merge pull request #18 from Novatux/master
Improved the code of the teleport tube.
Diffstat (limited to 'teleport_tube.lua')
-rw-r--r--teleport_tube.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/teleport_tube.lua b/teleport_tube.lua
index b636431..ac1a613 100644
--- a/teleport_tube.lua
+++ b/teleport_tube.lua
@@ -41,11 +41,19 @@ end
function get_tubes_in_file(pos,channel)
tbl=read_file()
newtbl={}
+ changed=false
for _,val in ipairs(tbl) do
+ local node = minetest.env:get_node(val)
+ local meta = minetest.env:get_meta(val)
+ if node.name~="ignore" and val.channel~=meta:get_string("channel") then
+ val.channel=meta:get_string("channel")
+ changed=true
+ end
if val.channel==channel and (val.x~=pos.x or val.y~=pos.y or val.z~=pos.z) then
table.insert(newtbl,val)
end
end
+ if changed then write_file(tbl) end
return newtbl
end
@@ -85,6 +93,6 @@ register_tube("pipeworks:teleport_tube","Teleporter pneumatic tube segment",tele
remove_tube_in_file(pos)
add_tube_in_file(pos,fields.channel)
end,
- after_dig_node = function(pos)
+ on_destruct = function(pos)
remove_tube_in_file(pos)
end})