diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2012-08-20 03:46:24 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2012-08-20 03:46:24 -0400 |
commit | 4b0b137f948f3d07f4146679bee75d98363da91b (patch) | |
tree | 405214162efec49f22d81d33fe8fdf298903c321 | |
parent | c1dffa70f0539d591024c1a623dbc5c9338831c3 (diff) | |
download | pipeworks-4b0b137f948f3d07f4146679bee75d98363da91b.tar pipeworks-4b0b137f948f3d07f4146679bee75d98363da91b.tar.gz pipeworks-4b0b137f948f3d07f4146679bee75d98363da91b.tar.bz2 pipeworks-4b0b137f948f3d07f4146679bee75d98363da91b.tar.xz pipeworks-4b0b137f948f3d07f4146679bee75d98363da91b.zip |
Added some metadata to the valve, grate, storage tank to make flow calculation
easier. Ask RealBadAngel about it :-)
-rw-r--r-- | devices.lua | 94 |
1 files changed, 61 insertions, 33 deletions
diff --git a/devices.lua b/devices.lua index f13fab6..71e8eac 100644 --- a/devices.lua +++ b/devices.lua @@ -173,7 +173,12 @@ for s in ipairs(states) do after_dig_node = function(pos) pipe_scanforobjects(pos) end, - drop = "pipeworks:valve_off_x" + drop = "pipeworks:valve_off_x", + pipelike=1, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_int("pipelike",1) + end, }) local valveboxes = {} @@ -218,38 +223,15 @@ for s in ipairs(states) do after_dig_node = function(pos) pipe_scanforobjects(pos) end, - drop = "pipeworks:valve_off_x" + drop = "pipeworks:valve_off_x", + pipelike=1, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_int("pipelike",1) + end, }) end -local axes = { "x", "z" } - -for a in ipairs(axes) do - minetest.register_on_punchnode(function (pos, node) - if node.name=="pipeworks:valve_on_"..axes[a] then - minetest.env:add_node(pos, { name = "pipeworks:valve_off_"..axes[a] }) - end - end) - - minetest.register_on_punchnode(function (pos, node) - if node.name=="pipeworks:valve_off_"..axes[a] then - minetest.env:add_node(pos, { name = "pipeworks:valve_on_"..axes[a] }) - end - end) - - minetest.register_on_punchnode(function (pos, node) - if node.name=="pipeworks:pump_on_"..axes[a] then - minetest.env:add_node(pos, { name = "pipeworks:pump_off_"..axes[a] }) - end - end) - - minetest.register_on_punchnode(function (pos, node) - if node.name=="pipeworks:pump_off_"..axes[a] then - minetest.env:add_node(pos, { name = "pipeworks:pump_on_"..axes[a] }) - end - end) -end - -- intake grate minetest.register_node("pipeworks:intake", { @@ -275,7 +257,12 @@ minetest.register_node("pipeworks:intake", { groups = {snappy=3, pipe=1}, sounds = default.node_sound_wood_defaults(), walkable = true, - stack_max = 99 + stack_max = 99, + pipelike=1, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_int("pipelike",1) + end, }) -- tank @@ -294,7 +281,12 @@ minetest.register_node("pipeworks:storage_tank_x", { groups = {snappy=3, pipe=1}, sounds = default.node_sound_wood_defaults(), walkable = true, - stack_max = 99 + stack_max = 99, + pipelike=1, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_int("pipelike",1) + end, }) minetest.register_node("pipeworks:storage_tank_z", { @@ -311,8 +303,44 @@ minetest.register_node("pipeworks:storage_tank_z", { groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, sounds = default.node_sound_wood_defaults(), walkable = true, - stack_max = 99 + stack_max = 99, + pipelike=1, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_int("pipelike",1) + end, }) +-- various actions + +local axes = { "x", "z" } + +for a in ipairs(axes) do + minetest.register_on_punchnode(function (pos, node) + if node.name=="pipeworks:valve_on_"..axes[a] then + minetest.env:add_node(pos, { name = "pipeworks:valve_off_"..axes[a] }) + meta:set_int("pipelike",0) + end + end) + + minetest.register_on_punchnode(function (pos, node) + if node.name=="pipeworks:valve_off_"..axes[a] then + minetest.env:add_node(pos, { name = "pipeworks:valve_on_"..axes[a] }) + meta:set_int("pipelike",1) + end + end) + + minetest.register_on_punchnode(function (pos, node) + if node.name=="pipeworks:pump_on_"..axes[a] then + minetest.env:add_node(pos, { name = "pipeworks:pump_off_"..axes[a] }) + end + end) + + minetest.register_on_punchnode(function (pos, node) + if node.name=="pipeworks:pump_off_"..axes[a] then + minetest.env:add_node(pos, { name = "pipeworks:pump_on_"..axes[a] }) + end + end) +end print("Pipeworks loaded!") |