diff options
author | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-09-27 16:42:15 +0100 |
---|---|---|
committer | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-09-27 16:42:15 +0100 |
commit | d6dcd51302633e952b023526da0fe33d3759e2f8 (patch) | |
tree | fb485f2e5cd99c1713e3a8ae3d8e33636e953fe6 | |
parent | c3708b154c8b81d4ec65cbf736f55864519ef01f (diff) | |
download | pipeworks-d6dcd51302633e952b023526da0fe33d3759e2f8.tar pipeworks-d6dcd51302633e952b023526da0fe33d3759e2f8.tar.gz pipeworks-d6dcd51302633e952b023526da0fe33d3759e2f8.tar.bz2 pipeworks-d6dcd51302633e952b023526da0fe33d3759e2f8.tar.xz pipeworks-d6dcd51302633e952b023526da0fe33d3759e2f8.zip |
devices.lua: replace calls to add_node() with swap_node() to preserve node metadata
-rw-r--r-- | devices.lua | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/devices.lua b/devices.lua index 0121e2f..3b7fc78 100644 --- a/devices.lua +++ b/devices.lua @@ -68,7 +68,7 @@ function pipeworks.rotate_on_place(itemstack, placer, pointed_thing) local placednode = string.gsub(itemstack:get_name(), "_loaded", "_empty") placednode = string.gsub(placednode, "_on", "_off") - minetest.add_node(pos1, {name = placednode, param2 = fdir }) + minetest.swap_node(pos1, {name = placednode, param2 = fdir }) pipeworks.scan_for_pipe_objects(pos1) if not pipeworks.expect_infinite_stacks then @@ -149,16 +149,17 @@ for s in ipairs(states) do drop = "pipeworks:pump_off", mesecons = {effector = { action_on = function (pos, node) - minetest.add_node(pos,{name="pipeworks:pump_on", param2 = node.param2}) + minetest.swap_node(pos,{name="pipeworks:pump_on", param2 = node.param2}) end, action_off = function (pos, node) - minetest.add_node(pos,{name="pipeworks:pump_off", param2 = node.param2}) + minetest.swap_node(pos,{name="pipeworks:pump_off", param2 = node.param2}) end }}, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) local fdir = node.param2 - minetest.add_node(pos, { name = "pipeworks:pump_"..states[3-s], param2 = fdir }) + minetest.swap_node(pos, { name = "pipeworks:pump_"..states[3-s], param2 = fdir }) end, + -- FIXME - does this preserve metadata? need to look at this on_rotate = screwdriver.rotate_simple }) @@ -188,15 +189,15 @@ for s in ipairs(states) do drop = "pipeworks:valve_off_empty", mesecons = {effector = { action_on = function (pos, node) - minetest.add_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2}) + minetest.swap_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2}) end, action_off = function (pos, node) - minetest.add_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2}) + minetest.swap_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2}) end }}, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) local fdir = node.param2 - minetest.add_node(pos, { name = "pipeworks:valve_"..states[3-s].."_empty", param2 = fdir }) + minetest.swap_node(pos, { name = "pipeworks:valve_"..states[3-s].."_empty", param2 = fdir }) end, on_rotate = pipeworks.fix_after_rotation }) @@ -228,15 +229,15 @@ minetest.register_node("pipeworks:valve_on_loaded", { drop = "pipeworks:valve_off_empty", mesecons = {effector = { action_on = function (pos, node) - minetest.add_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2}) + minetest.swap_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2}) end, action_off = function (pos, node) - minetest.add_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2}) + minetest.swap_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2}) end }}, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) local fdir = node.param2 - minetest.add_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir }) + minetest.swap_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir }) end, on_rotate = pipeworks.fix_after_rotation }) |