diff options
Diffstat (limited to 'jeija/temperest.lua')
-rw-r--r-- | jeija/temperest.lua | 132 |
1 files changed, 54 insertions, 78 deletions
diff --git a/jeija/temperest.lua b/jeija/temperest.lua index 7fa61e3..6a3214f 100644 --- a/jeija/temperest.lua +++ b/jeija/temperest.lua @@ -1,106 +1,82 @@ --TEMPEREST-PLUG minetest.register_node("jeija:mesecon_plug", { - description = "Plug", drawtype = "raillike", paramtype = "light", is_ground_content = true, tile_images = {"jeija_mesecon_plug.png"}, inventory_image = "jeija_mesecon_plug.png", + wield_image = "jeija_mesecon_plug.png", material = minetest.digprop_constanttime(0.1), walkable = false, selection_box = { type = "fixed", }, + description = "Plug", }) -mesecon:register_on_signal_on(function(pos, node) - if node.name=="jeija:mesecon_plug" then - local set_node_on = function(pos) - local node = minetest.env:get_node(pos) - if node.name=="jeija:mesecon_socket_off" then - minetest.env:add_node(pos, {name="jeija:mesecon_socket_on"}) - nodeupdate(pos) - mesecon:receptor_on(pos) - elseif node.name=="jeija:mesecon_inverter_on" then - minetest.env:add_node(pos, {name="jeija:mesecon_inverter_off"}) - nodeupdate(pos) - mesecon:receptor_off(pos) - end - end - - local lnode = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_on({x=pos.x-2, y=pos.y, z=pos.z}) end - - local lnode = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_on({x=pos.x+2, y=pos.y, z=pos.z}) end - - local lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y, z=pos.z-2}) end - - local lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z+1}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y, z=pos.z+2}) end - end -end) - -mesecon:register_on_signal_off(function(pos, node) - if node.name=="jeija:mesecon_plug" then - local set_node_off = function(pos) - node = minetest.env:get_node(pos) - if node.name=="jeija:mesecon_socket_on" then - minetest.env:add_node(pos, {name="jeija:mesecon_socket_off"}) - nodeupdate(pos) - mesecon:receptor_off(pos) - elseif node.name=="jeija:mesecon_inverter_off" then - minetest.env:add_node(pos, {name="jeija:mesecon_inverter_on"}) - nodeupdate(pos) - mesecon:receptor_on(pos) - end - end - - lnode = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_off({x=pos.x-2, y=pos.y, z=pos.z}) end - - lnode = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_off({x=pos.x+2, y=pos.y, z=pos.z}) end - - lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y, z=pos.z-2}) end - - lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z+1}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y, z=pos.z+2}) end +local set_node_on = function(pos) + local node = minetest.env:get_node(pos) + if node.name=="jeija:mesecon_socket_off" then + minetest.env:add_node(pos, {name="jeija:mesecon_socket_on"}) + nodeupdate(pos) + mesecon:receptor_on(pos) + elseif node.name=="jeija:mesecon_inverter_on" then + minetest.env:add_node(pos, {name="jeija:mesecon_inverter_off"}) + nodeupdate(pos) + mesecon:receptor_off(pos) end -end) +end -minetest.register_on_dignode(function(pos, oldnode, digger) - if oldnode.name == "jeija:mesecon_plug" then - local set_node_deactivated = function(pos) +local set_node_off = function(pos) node = minetest.env:get_node(pos) if node.name=="jeija:mesecon_socket_on" then minetest.env:add_node(pos, {name="jeija:mesecon_socket_off"}) nodeupdate(pos) mesecon:receptor_off(pos) - elseif node.name=="jeija:mesecon_inverter_on" then - minetest.env:add_node(pos, {name="jeija:mesecon_inverter_off"}) + elseif node.name=="jeija:mesecon_inverter_off" then + minetest.env:add_node(pos, {name="jeija:mesecon_inverter_on"}) nodeupdate(pos) - mesecon:receptor_off(pos) + mesecon:receptor_on(pos) end +end + +local plug_on = function(pos, node) + if node.name=="jeija:mesecon_plug" then + local lnode = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away + if lnode.name=="air" then set_node_on({x=pos.x-2, y=pos.y, z=pos.z}) end + + local lnode = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away + if lnode.name=="air" then set_node_on({x=pos.x+2, y=pos.y, z=pos.z}) end + + local lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) --a node between this node and the one two nodes away + if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y, z=pos.z-2}) end + + local lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z+1}) --a node between this node and the one two nodes away + if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y, z=pos.z+2}) end end - - lnode = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_deactivated({x=pos.x-2, y=pos.y, z=pos.z}) end - - lnode = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_deactivated({x=pos.x+2, y=pos.y, z=pos.z}) end - - lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_deactivated({x=pos.x, y=pos.y, z=pos.z-2}) end - - lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z+1}) --a node between this node and the one two nodes away - if lnode.name=="air" then set_node_deactivated({x=pos.x, y=pos.y, z=pos.z+2}) end +end + +local plug_off = function(pos, node) + if node.name=="jeija:mesecon_plug" then + lnode = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away + if lnode.name=="air" then set_node_off({x=pos.x-2, y=pos.y, z=pos.z}) end + + lnode = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away + if lnode.name=="air" then set_node_off({x=pos.x+2, y=pos.y, z=pos.z}) end + + lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) --a node between this node and the one two nodes away + if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y, z=pos.z-2}) end + + lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z+1}) --a node between this node and the one two nodes away + if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y, z=pos.z+2}) end end -end) +end + +mesecon:register_on_signal_on(plug_on) +mesecon:register_on_signal_off(plug_off) +minetest.register_on_dignode(plug_off) minetest.register_craft({ output = 'node "jeija:mesecon_plug" 2', @@ -120,6 +96,7 @@ minetest.register_node("jeija:mesecon_socket_off", { is_ground_content = true, tile_images = {"jeija_mesecon_socket_off.png"}, inventory_image = "jeija_mesecon_socket_off.png", + wield_image = "jeija_mesecon_socket_off.png", material = minetest.digprop_constanttime(0.1), walkable = false, selection_box = { @@ -132,7 +109,6 @@ minetest.register_node("jeija:mesecon_socket_on", { paramtype = "light", is_ground_content = true, tile_images = {"jeija_mesecon_socket_on.png"}, - inventory_image = "jeija_mesecon_socket_on.png", material = minetest.digprop_constanttime(0.1), walkable = false, selection_box = { @@ -170,6 +146,7 @@ minetest.register_node("jeija:mesecon_inverter_off", { is_ground_content = true, tile_images = {"jeija_mesecon_inverter_off.png"}, inventory_image = "jeija_mesecon_inverter_off.png", + wield_image = "jeija_mesecon_inverter_off.png", material = minetest.digprop_constanttime(0.1), walkable = false, selection_box = { @@ -182,7 +159,6 @@ minetest.register_node("jeija:mesecon_inverter_on", { paramtype = "light", is_ground_content = true, tile_images = {"jeija_mesecon_inverter_on.png"}, - inventory_image = "jeija_mesecon_inverter_on.png", material = minetest.digprop_constanttime(0.1), walkable = false, selection_box = { |