summaryrefslogtreecommitdiff
path: root/deployer.lua
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2013-12-21 10:24:55 +0100
committerNovatux <nathanael.courant@laposte.net>2013-12-21 10:24:55 +0100
commit5a2d57b48523b95aad2294f88da3e03cf35b9942 (patch)
tree7cb305044b31e2fc6ccfc106a87fab42b42bc86d /deployer.lua
parent75db2c530792b300fc8dfe0213a7db41a6402fa6 (diff)
downloadpipeworks-5a2d57b48523b95aad2294f88da3e03cf35b9942.tar
pipeworks-5a2d57b48523b95aad2294f88da3e03cf35b9942.tar.gz
pipeworks-5a2d57b48523b95aad2294f88da3e03cf35b9942.tar.bz2
pipeworks-5a2d57b48523b95aad2294f88da3e03cf35b9942.tar.xz
pipeworks-5a2d57b48523b95aad2294f88da3e03cf35b9942.zip
Fix node breaker, use new minetest.swap_node
Diffstat (limited to 'deployer.lua')
-rw-r--r--deployer.lua20
1 files changed, 8 insertions, 12 deletions
diff --git a/deployer.lua b/deployer.lua
index f5f8171..e67250c 100644
--- a/deployer.lua
+++ b/deployer.lua
@@ -66,33 +66,29 @@ minetest.register_craft({
}
})
-local function hacky_swap_node(pos,name)
- local node=minetest.get_node(pos)
- local meta=minetest.get_meta(pos)
- local meta0=meta:to_table()
+local function swap_node(pos, name)
+ local node = minetest.get_node(pos)
if node.name == name then
return
end
- node.name=name
- minetest.add_node(pos, node)
- local meta=minetest.get_meta(pos)
- meta:from_table(meta0)
+ node.name = name
+ minetest.swap_node(pos, node)
end
local function delay(x)
return (function() return x end)
end
-local deployer_on = function(pos, node)
+local function deployer_on(pos, node)
if node.name ~= "pipeworks:deployer_off" then
return
end
--locate the above and under positions
local dir = minetest.facedir_to_dir(node.param2)
- local pos_under, pos_above = {x=pos.x - dir.x, y=pos.y - dir.y, z=pos.z - dir.z}, {x=pos.x - 2*dir.x, y=pos.y - 2*dir.y, z=pos.z - 2*dir.z}
+ local pos_under, pos_above = {x = pos.x - dir.x, y = pos.y - dir.y, z = pos.z - dir.z}, {x = pos.x - 2*dir.x, y = pos.y - 2*dir.y, z = pos.z - 2*dir.z}
- hacky_swap_node(pos,"pipeworks:deployer_on")
+ swap_node(pos, "pipeworks:deployer_on")
nodeupdate(pos)
local meta = minetest.get_meta(pos)
@@ -163,7 +159,7 @@ end
local deployer_off = function(pos, node)
if node.name == "pipeworks:deployer_on" then
- hacky_swap_node(pos,"pipeworks:deployer_off")
+ swap_node(pos, "pipeworks:deployer_off")
nodeupdate(pos)
end
end