diff --git a/autocrafter.lua b/autocrafter.lua index b4954b6f..af29ccc7 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -511,10 +511,6 @@ minetest.register_node("pipeworks:autocrafter", { local inv = meta:get_inventory() return (inv:is_empty("src") and inv:is_empty("dst")) end, - after_place_node = pipeworks.scan_for_tube_objects, - after_dig_node = function(pos) - pipeworks.scan_for_tube_objects(pos) - end, on_destruct = function(pos) autocrafterCache[minetest.hash_node_position(pos)] = nil end, diff --git a/autoplace_tubes.lua b/autoplace_tubes.lua deleted file mode 100644 index 9f4e112a..00000000 --- a/autoplace_tubes.lua +++ /dev/null @@ -1,139 +0,0 @@ --- autorouting for pneumatic tubes - -local function is_tube(nodename) - return pipeworks.table_contains(pipeworks.tubenodes, nodename) -end - ---a function for determining which side of the node we are on -local function nodeside(node, tubedir) - if node.param2 < 0 or node.param2 > 23 then - node.param2 = 0 - end - - local backdir = minetest.facedir_to_dir(node.param2) - local back = vector.dot(backdir, tubedir) - if back == 1 then - return "back" - elseif back == -1 then - return "front" - end - - local topdir = pipeworks.facedir_to_top_dir(node.param2) - local top = vector.dot(topdir, tubedir) - if top == 1 then - return "top" - elseif top == -1 then - return "bottom" - end - - local rightdir = pipeworks.facedir_to_right_dir(node.param2) - local right = vector.dot(rightdir, tubedir) - if right == 1 then - return "right" - else - return "left" - end -end - -local vts = {0, 3, 1, 4, 2, 5} -local tube_table = {[0] = 1, 2, 2, 4, 2, 4, 4, 5, 2, 3, 4, 6, 4, 6, 5, 7, 2, 4, 3, 6, 4, 5, 6, 7, 4, 6, 6, 8, 5, 7, 7, 9, 2, 4, 4, 5, 3, 6, 6, 7, 4, 6, 5, 7, 6, 8, 7, 9, 4, 5, 6, 7, 6, 7, 8, 9, 5, 7, 7, 9, 7, 9, 9, 10} -local tube_table_facedirs = {[0] = 0, 0, 5, 0, 3, 4, 3, 0, 2, 0, 2, 0, 6, 4, 3, 0, 7, 12, 5, 12, 7, 4, 5, 5, 18, 20, 16, 0, 7, 4, 7, 0, 1, 8, 1, 1, 1, 13, 1, 1, 10, 8, 2, 2, 17, 4, 3, 6, 9, 9, 9, 9, 21, 13, 1, 1, 10, 10, 11, 2, 19, 4, 3, 0} -local function tube_autoroute(pos) - local active = {0, 0, 0, 0, 0, 0} - local nctr = minetest.get_node(pos) - if not is_tube(nctr.name) then return end - - local adjustments = { - {x = -1, y = 0, z = 0}, - {x = 1, y = 0, z = 0}, - {x = 0, y = -1, z = 0}, - {x = 0, y = 1, z = 0}, - {x = 0, y = 0, z = -1}, - {x = 0, y = 0, z = 1} - } - -- xm = 1, xp = 2, ym = 3, yp = 4, zm = 5, zp = 6 - - local adjlist = {} -- this will be used in item_transport - - for i, adj in ipairs(adjustments) do - local position = vector.add(pos, adj) - local node = minetest.get_node(position) - - local idef = minetest.registered_nodes[node.name] - -- handle the tubes themselves - if is_tube(node.name) then - active[i] = 1 - table.insert(adjlist, adj) - -- handle new style connectors - elseif idef and idef.tube and idef.tube.connect_sides then - if idef.tube.connect_sides[nodeside(node, vector.multiply(adj, -1))] then - active[i] = 1 - table.insert(adjlist, adj) - end - end - end - - minetest.get_meta(pos):set_string("adjlist", minetest.serialize(adjlist)) - - -- all sides checked, now figure which tube to use. - - local nodedef = minetest.registered_nodes[nctr.name] - local basename = nodedef.basename - if nodedef.style == "old" then - local nsurround = "" - for _, n in ipairs(active) do - nsurround = nsurround..n - end - nctr.name = basename.."_"..nsurround - elseif nodedef.style == "6d" then - local s = 0 - for i, n in ipairs(active) do - if n == 1 then - s = s + 2^vts[i] - end - end - nctr.name = basename.."_"..tube_table[s] - nctr.param2 = tube_table_facedirs[s] - end - minetest.swap_node(pos, nctr) -end - -function pipeworks.scan_for_tube_objects(pos) - for side = 0, 6 do - tube_autoroute(vector.add(pos, pipeworks.directions.side_to_dir(side))) - end -end - -function pipeworks.after_place(pos) - pipeworks.scan_for_tube_objects(pos) -end - -function pipeworks.after_dig(pos) - pipeworks.scan_for_tube_objects(pos) -end - --- Screwdriver calls this function before rotating a node. --- However, connections must be updated *after* the node is rotated --- So, this function does the rotation itself and returns `true`. --- (Note: screwdriver already checks for protected areas.) - --- This should only be used for tubes that don't autoconnect. --- (For example, one-way tubes.) --- Autoconnecting tubes will just revert back to their original state --- when they are updated. -function pipeworks.on_rotate(pos, node, user, mode, new_param2) - node.param2 = new_param2 - minetest.swap_node(pos, node) - pipeworks.scan_for_tube_objects(pos) - return true -end - -if minetest.get_modpath("mesecons_mvps") then - mesecon.register_on_mvps_move(function(moved_nodes) - for _, n in ipairs(moved_nodes) do - pipeworks.scan_for_tube_objects(n.pos) - pipeworks.scan_for_tube_objects(n.oldpos) - end - end) -end - diff --git a/chests.lua b/chests.lua index 74b658e1..99616a37 100644 --- a/chests.lua +++ b/chests.lua @@ -9,6 +9,7 @@ pipeworks.chests = {} -- @param connect_sides: which directions the chests shall connect to function pipeworks.override_chest(chestname, override, connect_sides) local old_def = minetest.registered_nodes[chestname] + local nodebox_connection = {} local tube_entry = "^pipeworks_tube_connection_wooden.png" override.tiles = override.tiles or old_def.tiles @@ -22,6 +23,7 @@ function pipeworks.override_chest(chestname, override, connect_sides) local tile_directions = {"top", "bottom", "right", "left", "back", "front"} for i, direction in ipairs(tile_directions) do if connect_sides[direction] then + table.insert( nodebox_connection, direction ) if type(override.tiles[i]) == "string" then override.tiles[i] = override.tiles[i] .. tube_entry elseif type(override.tiles[i]) == "table" and not override.tiles[i].animation then @@ -30,38 +32,6 @@ function pipeworks.override_chest(chestname, override, connect_sides) end end - local old_after_place_node = override.after_place_node or old_def.after_place_node or function() end - override.after_place_node = function(pos, placer, itemstack, pointed_thing) - old_after_place_node(pos, placer, itemstack, pointed_thing) - pipeworks.after_place(pos) - end - - local old_after_dig = override.after_dig or old_def.after_dig_node or function() end - override.after_dig_node = function(pos, oldnode, oldmetadata, digger) - old_after_dig(pos, oldnode, oldmetadata, digger) - pipeworks.after_dig(pos, oldnode, oldmetadata, digger) - end - - local old_on_rotate - if override.on_rotate ~= nil then - old_on_rotate = override.on_rotate - elseif old_def.on_rotate ~= nil then - old_on_rotate = old_def.on_rotate - else - old_on_rotate = function() end - end - -- on_rotate = false -> rotation disabled, no need to update tubes - -- everything else: undefined by the most common screwdriver mods - if type(old_on_rotate) == "function" then - override.on_rotate = function(pos, node, user, mode, new_param2) - if old_on_rotate(pos, node, user, mode, new_param2) ~= false then - return pipeworks.on_rotate(pos, node, user, mode, new_param2) - else - return false - end - end - end - override.tube = { insert_object = function(pos, node, stack, direction) local meta = minetest.get_meta(pos) @@ -84,6 +54,7 @@ function pipeworks.override_chest(chestname, override, connect_sides) override.groups = override.groups or old_def.groups or {} override.groups.tubedevice = 1 override.groups.tubedevice_receiver = 1 + override.connect_sides = nodebox_connection minetest.override_item(chestname, override) pipeworks.chests[chestname] = true diff --git a/compat-furnaces.lua b/compat-furnaces.lua index c4cbd86c..76777326 100644 --- a/compat-furnaces.lua +++ b/compat-furnaces.lua @@ -62,9 +62,7 @@ local override = { connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} }, - after_place_node = pipeworks.after_place, - after_dig_node = pipeworks.after_dig, - on_rotate = pipeworks.on_rotate + connect_sides = {"left", "right", "back", "bottom", "top"} } local override_active = { @@ -113,9 +111,7 @@ local override_active = { connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} }, - after_place_node = pipeworks.after_place, - after_dig_node = pipeworks.after_dig, - on_rotate = pipeworks.on_rotate + connect_sides = {"left", "right", "back", "bottom", "top"} } if minetest.get_modpath("default") then diff --git a/filter-injector.lua b/filter-injector.lua index cac48587..39cb7b42 100644 --- a/filter-injector.lua +++ b/filter-injector.lua @@ -425,10 +425,7 @@ for _, data in ipairs({ end, after_place_node = function (pos, placer) minetest.get_meta(pos):set_string("owner", placer:get_player_name()) - pipeworks.after_place(pos) end, - after_dig_node = pipeworks.after_dig, - on_rotate = pipeworks.on_rotate, allow_metadata_inventory_put = function(pos, listname, index, stack, player) if not pipeworks.may_configure(pos, player) then return 0 @@ -452,6 +449,7 @@ for _, data in ipairs({ return count end, tube = {connect_sides = {right = 1}}, + connect_sides = {"right"}, } if data.digiline then diff --git a/init.lua b/init.lua index 6d85a066..541e3d7f 100644 --- a/init.lua +++ b/init.lua @@ -54,7 +54,6 @@ end dofile(pipeworks.modpath.."/common.lua") dofile(pipeworks.modpath.."/models.lua") dofile(pipeworks.modpath.."/autoplace_pipes.lua") -dofile(pipeworks.modpath.."/autoplace_tubes.lua") dofile(pipeworks.modpath.."/luaentity.lua") dofile(pipeworks.modpath.."/item_transport.lua") dofile(pipeworks.modpath.."/flowing_logic.lua") diff --git a/item_transport.lua b/item_transport.lua index ddf2a08c..10298d74 100644 --- a/item_transport.lua +++ b/item_transport.lua @@ -87,7 +87,6 @@ function pipeworks.break_tube(pos) local meta = minetest.get_meta(pos) meta:set_string("the_tube_was", minetest.serialize(node)) minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) - pipeworks.scan_for_tube_objects(pos) end local crunch_tube = function(pos, cnode, cmeta) diff --git a/mcl_furnaces.lua b/mcl_furnaces.lua index e23a297c..a0266b4d 100644 --- a/mcl_furnaces.lua +++ b/mcl_furnaces.lua @@ -76,18 +76,9 @@ override.tube = { end end, input_inventory = "dst", - connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} + connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}, } -override.after_place_node = function(pos, placer, itemstack, pointed_thing) - pipeworks.after_place(pos, placer, itemstack, pointed_thing) -end - -override.after_dig_node = function(pos, oldnode, oldmetadata, digger) - old_furnace.after_dig_node(pos, oldnode, oldmetadata, digger) - pipeworks.after_dig(pos) -end - override.on_metadata_inventory_take = function(pos, listname, index, stack, player) if listname == "dst" then if stack:get_name() == "mcl_core:iron_ingot" then @@ -99,8 +90,7 @@ override.on_metadata_inventory_take = function(pos, listname, index, stack, play end end -override.on_rotate = pipeworks.on_rotate - +override.connect_sides = {"left", "right", "back", "bottom", "top"} local override_active = table.copy(override) @@ -188,15 +178,6 @@ override_blast_furnace.tube = { connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} } -override_blast_furnace.after_place_node = function(pos, placer, itemstack, pointed_thing) - pipeworks.after_place(pos, placer, itemstack, pointed_thing) -end - -override_blast_furnace.after_dig_node = function(pos, oldnode, oldmetadata, digger) - old_blast_furnace.after_dig_node(pos, oldnode, oldmetadata, digger) - pipeworks.after_dig(pos) -end - override_blast_furnace.on_metadata_inventory_take = function(pos, listname, index, stack, player) -- Award smelting achievements if listname == "dst" then @@ -207,9 +188,6 @@ override_blast_furnace.on_metadata_inventory_take = function(pos, listname, inde end end -override_blast_furnace.on_rotate = pipeworks.on_rotate - - local override_blast_active = table.copy(override) override_blast_active.tiles = { @@ -299,15 +277,6 @@ override_smoker.tube = { connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} } -override_smoker.after_place_node = function(pos, placer, itemstack, pointed_thing) - pipeworks.after_place(pos, placer, itemstack, pointed_thing) -end - -override_smoker.after_dig_node = function(pos, oldnode, oldmetadata, digger) - old_smoker.after_dig_node(pos, oldnode, oldmetadata, digger) - pipeworks.after_dig(pos) -end - override_smoker.on_metadata_inventory_take = function(pos, listname, index, stack, player) -- Award fish achievements if listname == "dst" then @@ -318,9 +287,6 @@ override_smoker.on_metadata_inventory_take = function(pos, listname, index, stac end end -override_smoker.on_rotate = pipeworks.on_rotate - - local override_smoker_active = table.copy(override) override_smoker_active.tiles = { diff --git a/textures/pipeworks_accelerator_tube_plain.png b/textures/pipeworks_accelerator_tube_plain.png index 8256d05e..f06000b6 100644 Binary files a/textures/pipeworks_accelerator_tube_plain.png and b/textures/pipeworks_accelerator_tube_plain.png differ diff --git a/textures/pipeworks_broken_tube_plain.png b/textures/pipeworks_broken_tube_plain.png index 7957e59a..69265d1b 100644 Binary files a/textures/pipeworks_broken_tube_plain.png and b/textures/pipeworks_broken_tube_plain.png differ diff --git a/textures/pipeworks_conductor_tube_on_plain.png b/textures/pipeworks_conductor_tube_on_plain.png index c58eaf24..d275a85a 100644 Binary files a/textures/pipeworks_conductor_tube_on_plain.png and b/textures/pipeworks_conductor_tube_on_plain.png differ diff --git a/textures/pipeworks_conductor_tube_plain.png b/textures/pipeworks_conductor_tube_plain.png index e0891ed6..6962d3d8 100644 Binary files a/textures/pipeworks_conductor_tube_plain.png and b/textures/pipeworks_conductor_tube_plain.png differ diff --git a/textures/pipeworks_crossing_tube_plain.png b/textures/pipeworks_crossing_tube_plain.png index 0ed695f1..a4ca3f62 100644 Binary files a/textures/pipeworks_crossing_tube_plain.png and b/textures/pipeworks_crossing_tube_plain.png differ diff --git a/textures/pipeworks_detector_tube_plain.png b/textures/pipeworks_detector_tube_plain.png index 6a9845cf..d9be82f9 100644 Binary files a/textures/pipeworks_detector_tube_plain.png and b/textures/pipeworks_detector_tube_plain.png differ diff --git a/textures/pipeworks_digiline_conductor_tube_plain.png b/textures/pipeworks_digiline_conductor_tube_plain.png index de313075..10ef9928 100644 Binary files a/textures/pipeworks_digiline_conductor_tube_plain.png and b/textures/pipeworks_digiline_conductor_tube_plain.png differ diff --git a/textures/pipeworks_digiline_detector_tube_plain.png b/textures/pipeworks_digiline_detector_tube_plain.png index 86ded6f9..1799b1ef 100644 Binary files a/textures/pipeworks_digiline_detector_tube_plain.png and b/textures/pipeworks_digiline_detector_tube_plain.png differ diff --git a/textures/pipeworks_mese_sand_tube_plain.png b/textures/pipeworks_mese_sand_tube_plain.png index 8a48599d..8fb74a76 100644 Binary files a/textures/pipeworks_mese_sand_tube_plain.png and b/textures/pipeworks_mese_sand_tube_plain.png differ diff --git a/textures/pipeworks_mese_tube_plain_1.png b/textures/pipeworks_mese_tube_plain_1.png index 47ce4ed8..e84088e8 100644 Binary files a/textures/pipeworks_mese_tube_plain_1.png and b/textures/pipeworks_mese_tube_plain_1.png differ diff --git a/textures/pipeworks_mese_tube_plain_2.png b/textures/pipeworks_mese_tube_plain_2.png index 12d79665..9d8d433a 100644 Binary files a/textures/pipeworks_mese_tube_plain_2.png and b/textures/pipeworks_mese_tube_plain_2.png differ diff --git a/textures/pipeworks_mese_tube_plain_3.png b/textures/pipeworks_mese_tube_plain_3.png index 4d3d415a..b20eb0f9 100644 Binary files a/textures/pipeworks_mese_tube_plain_3.png and b/textures/pipeworks_mese_tube_plain_3.png differ diff --git a/textures/pipeworks_mese_tube_plain_4.png b/textures/pipeworks_mese_tube_plain_4.png index f4c33702..ee7a3bbf 100644 Binary files a/textures/pipeworks_mese_tube_plain_4.png and b/textures/pipeworks_mese_tube_plain_4.png differ diff --git a/textures/pipeworks_mese_tube_plain_5.png b/textures/pipeworks_mese_tube_plain_5.png index fbe8de00..2a528d42 100644 Binary files a/textures/pipeworks_mese_tube_plain_5.png and b/textures/pipeworks_mese_tube_plain_5.png differ diff --git a/textures/pipeworks_mese_tube_plain_6.png b/textures/pipeworks_mese_tube_plain_6.png index 76b49e36..72fa68ec 100644 Binary files a/textures/pipeworks_mese_tube_plain_6.png and b/textures/pipeworks_mese_tube_plain_6.png differ diff --git a/textures/pipeworks_one_way_tube.png b/textures/pipeworks_one_way_tube.png new file mode 100644 index 00000000..3fb6fc77 Binary files /dev/null and b/textures/pipeworks_one_way_tube.png differ diff --git a/textures/pipeworks_one_way_tube_port.png b/textures/pipeworks_one_way_tube_port.png new file mode 100644 index 00000000..dae1a7c2 Binary files /dev/null and b/textures/pipeworks_one_way_tube_port.png differ diff --git a/textures/pipeworks_pane.png b/textures/pipeworks_pane.png new file mode 100644 index 00000000..e8633671 Binary files /dev/null and b/textures/pipeworks_pane.png differ diff --git a/textures/pipeworks_pane_embedded_tube_sides.png b/textures/pipeworks_pane_embedded_tube_sides.png index befe5250..9c0fa76e 100644 Binary files a/textures/pipeworks_pane_embedded_tube_sides.png and b/textures/pipeworks_pane_embedded_tube_sides.png differ diff --git a/textures/pipeworks_sand_tube_plain.png b/textures/pipeworks_sand_tube_plain.png index d6650818..77d47529 100644 Binary files a/textures/pipeworks_sand_tube_plain.png and b/textures/pipeworks_sand_tube_plain.png differ diff --git a/textures/pipeworks_tag_tube_plain_1.png b/textures/pipeworks_tag_tube_plain_1.png index 69f9d66c..3df4ed7e 100644 Binary files a/textures/pipeworks_tag_tube_plain_1.png and b/textures/pipeworks_tag_tube_plain_1.png differ diff --git a/textures/pipeworks_tag_tube_plain_2.png b/textures/pipeworks_tag_tube_plain_2.png index 76aa7269..9dfa114e 100644 Binary files a/textures/pipeworks_tag_tube_plain_2.png and b/textures/pipeworks_tag_tube_plain_2.png differ diff --git a/textures/pipeworks_tag_tube_plain_3.png b/textures/pipeworks_tag_tube_plain_3.png index 98d68cba..3fba3c75 100644 Binary files a/textures/pipeworks_tag_tube_plain_3.png and b/textures/pipeworks_tag_tube_plain_3.png differ diff --git a/textures/pipeworks_tag_tube_plain_4.png b/textures/pipeworks_tag_tube_plain_4.png index b05fd696..2c87f33f 100644 Binary files a/textures/pipeworks_tag_tube_plain_4.png and b/textures/pipeworks_tag_tube_plain_4.png differ diff --git a/textures/pipeworks_tag_tube_plain_5.png b/textures/pipeworks_tag_tube_plain_5.png index 9801a38f..81ff712c 100644 Binary files a/textures/pipeworks_tag_tube_plain_5.png and b/textures/pipeworks_tag_tube_plain_5.png differ diff --git a/textures/pipeworks_tag_tube_plain_6.png b/textures/pipeworks_tag_tube_plain_6.png index 458fe5d2..e664db61 100644 Binary files a/textures/pipeworks_tag_tube_plain_6.png and b/textures/pipeworks_tag_tube_plain_6.png differ diff --git a/textures/pipeworks_teleport_tube_plain.png b/textures/pipeworks_teleport_tube_plain.png index 0a859f20..d512a058 100644 Binary files a/textures/pipeworks_teleport_tube_plain.png and b/textures/pipeworks_teleport_tube_plain.png differ diff --git a/textures/pipeworks_tube_plain.png b/textures/pipeworks_tube_plain.png index 9d6442b2..850e2233 100644 Binary files a/textures/pipeworks_tube_plain.png and b/textures/pipeworks_tube_plain.png differ diff --git a/trashcan.lua b/trashcan.lua index c8ae9b2e..ec8d90f3 100644 --- a/trashcan.lua +++ b/trashcan.lua @@ -1,5 +1,6 @@ local S = minetest.get_translator("pipeworks") -minetest.register_node("pipeworks:trashcan", { +local voidname = "pipeworks:trashcan" +minetest.register_node(voidname, { description = S("Trash Can"), drawtype = "normal", tiles = { @@ -43,10 +44,8 @@ minetest.register_node("pipeworks:trashcan", { meta:set_string("infotext", S("Trash Can")) meta:get_inventory():set_size("trash", 1) end, - after_place_node = pipeworks.after_place, - after_dig_node = pipeworks.after_dig, on_metadata_inventory_put = function(pos, listname, index, stack, player) minetest.get_meta(pos):get_inventory():set_stack(listname, index, ItemStack("")) end, }) -pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:trashcan" +pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = voidname diff --git a/tubes/embedded_tube.lua b/tubes/embedded_tube.lua index 0ca6e36d..81d610c1 100644 --- a/tubes/embedded_tube.lua +++ b/tubes/embedded_tube.lua @@ -45,9 +45,6 @@ function pipeworks.register_embedded_tube(nodename, opts) return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction) end }, - after_place_node = pipeworks.after_place, - after_dig_node = pipeworks.after_dig, - on_rotate = pipeworks.on_rotate, }) minetest.register_craft( { diff --git a/tubes/lua.lua b/tubes/lua.lua index ec09829d..95ea08f2 100644 --- a/tubes/lua.lua +++ b/tubes/lua.lua @@ -942,7 +942,6 @@ for white = 0, 1 do after_dig_node = function(pos, node) mesecon.do_cooldown(pos) mesecon.receptor_off(pos, output_rules) - pipeworks.after_dig(pos, node) end, is_luacontroller = true, on_timer = node_timer, @@ -994,14 +993,12 @@ for white = 0, 1 do return go_back(velocity) end, }, - after_place_node = pipeworks.after_place, on_blast = function(pos, intensity) if not intensity or intensity > 1 + 3^0.5 then minetest.remove_node(pos) return end minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) - pipeworks.scan_for_tube_objects(pos) end, }) end @@ -1076,15 +1073,12 @@ minetest.register_node(BASENAME .. "_burnt", { connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}, priority = 50, }, - after_place_node = pipeworks.after_place, - after_dig_node = pipeworks.after_dig, on_blast = function(pos, intensity) if not intensity or intensity > 1 + 3^0.5 then minetest.remove_node(pos) return end minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) - pipeworks.scan_for_tube_objects(pos) end, }) diff --git a/tubes/pane_embedded_tube.lua b/tubes/pane_embedded_tube.lua index 4bc1e833..1fc1d6c9 100644 --- a/tubes/pane_embedded_tube.lua +++ b/tubes/pane_embedded_tube.lua @@ -6,6 +6,7 @@ local pane_box = { type = "fixed", fixed = { { -9/64, -9/64, -8/16, 9/64, 9/64, 8/16 }, -- tube + { -12/64, -12/64, -12/64, 12/64, 12/64, 12/64 }, -- tube core { -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 } -- pane } } @@ -21,8 +22,8 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", { pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png^[transformR90"), pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png"), pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png"), - pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_ends.png"), - pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_ends.png"), + pipeworks.make_tube_tile("pipeworks_pane.png^pipeworks_one_way_tube_port.png"), + pipeworks.make_tube_tile("pipeworks_pane.png^pipeworks_one_way_tube_port.png"), }, use_texture_alpha = texture_alpha_mode, node_box = pane_box, @@ -46,8 +47,6 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", { return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction) end, }, - after_place_node = pipeworks.after_place, - after_dig_node = pipeworks.after_dig, - on_rotate = pipeworks.on_rotate, + connect_sides = {"front", "back"}, }) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:steel_pane_embedded_tube" diff --git a/tubes/registration.lua b/tubes/registration.lua index cbfc1506..5ec22f24 100644 --- a/tubes/registration.lua +++ b/tubes/registration.lua @@ -12,9 +12,7 @@ local REGISTER_COMPATIBILITY = true local vti = {4, 3, 2, 1, 6, 5} -local default_noctrs = { "pipeworks_tube_noctr.png" } local default_plain = { "pipeworks_tube_plain.png" } -local default_ends = { "pipeworks_tube_end.png" } local texture_mt = { __index = function(table, key) @@ -31,81 +29,48 @@ local texture_mt = { local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes and "clip" or true -local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style) - noctrs = noctrs or default_noctrs - setmetatable(noctrs, texture_mt) +local box = { + type = "connected", + connect_top = { -9/64, 9/64, -9/64, 9/64, 1/2, 9/64 }, + connect_bottom = { -9/64, -1/2, -9/64, 9/64,-9/64, 9/64 }, + connect_front = { -9/64, -9/64, -1/2, 9/64, 9/64,-9/64 }, + connect_back = { -9/64, -9/64, 9/64, 9/64, 9/64, 1/2 }, + connect_left = { -1/2, -9/64, -9/64,-9/64, 9/64, 9/64 }, + connect_right = { 9/64, -9/64, -9/64, 1/2, 9/64, 9/64 }, + fixed = { -12/64, -12/64, -12/64, 12/64, 12/64, 12/64 } +} + +local selbox = { + type = "connected", + connect_top = { -10/64, 10/64, -10/64, 10/64, 1/2, 10/64 }, + connect_bottom = { -10/64, -1/2, -10/64, 10/64,-10/64, 10/64 }, + connect_front = { -10/64, -10/64, -1/2, 10/64, 10/64,-10/64 }, + connect_back = { -10/64, -10/64, 10/64, 10/64, 10/64, 1/2 }, + connect_left = { -1/2, -10/64, -10/64,-10/64, 10/64, 10/64 }, + connect_right = { 10/64, -10/64, -10/64, 1/2, 10/64, 10/64 }, + fixed = { -13/64, -13/64, -13/64, 13/64, 13/64, 13/64 } +} + +local register_one_tube = function(name, tname, dropname, desc, plain, _, _, _, inv, special, connects, style) plain = plain or default_plain setmetatable(plain, texture_mt) - ends = ends or default_ends - setmetatable(ends, texture_mt) - short = short or "pipeworks_tube_short.png" inv = inv or "pipeworks_tube_inv.png" - local outboxes = {} - local outsel = {} - local outimgs = {} - - for i = 1, 6 do - outimgs[vti[i]] = plain[i] - end - - for _, v in ipairs(connects) do - pipeworks.table_extend(outboxes, pipeworks.tube_boxes[v]) - table.insert(outsel, pipeworks.tube_selectboxes[v]) - outimgs[vti[v]] = noctrs[v] - end - - if #connects == 1 then - local v = connects[1] - v = v-1 + 2*(v%2) -- Opposite side - outimgs[vti[v]] = ends[v] - end - - local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1} - local tubedesc = string.format("%s %s", desc, dump(connects)) - local iimg = type(plain[1]) == "table" and plain[1].name or plain[1] - local wscale = {x = 1, y = 1, z = 1} - - if #connects == 0 then - tgroups = {snappy = 3, tube = 1, tubedevice = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1} - tubedesc = desc - iimg=inv - outimgs = { - short, short, - ends[3],ends[4], - short, short - } - outboxes = { -24/64, -9/64, -9/64, 24/64, 9/64, 9/64 } - outsel = { -24/64, -10/64, -10/64, 24/64, 10/64, 10/64 } - wscale = {x = 1, y = 1, z = 0.01} - end - - for i, tile in ipairs(outimgs) do - outimgs[i] = pipeworks.make_tube_tile(tile) - end - - local rname = string.format("%s_%s", name, tname) - table.insert(tubenodes, rname) + table.insert(tubenodes, name) local nodedef = { - description = tubedesc, + description = desc, drawtype = "nodebox", - tiles = outimgs, + tiles = plain, use_texture_alpha = texture_alpha_mode, sunlight_propagates = true, - inventory_image = iimg, - wield_image = iimg, - wield_scale = wscale, + inventory_image = inv, + wield_image = inv, + wield_scale = {x = 1, y = 1, z = 0.01}, paramtype = "light", - selection_box = { - type = "fixed", - fixed = outsel - }, - node_box = { - type = "fixed", - fixed = outboxes - }, - groups = tgroups, + selection_box = selbox, + node_box = box, + groups = {snappy = 3, tube = 1, tubedevice = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, is_ground_content = false, _mcl_hardness=0.8, _sound_def = { @@ -113,6 +78,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e }, walkable = true, basename = name, + connects_to = {"group:tubedevice","group:injector"}, style = style, drop = string.format("%s_%s", name, dropname), tubelike = 1, @@ -132,24 +98,18 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e end return minetest.node_punch(pos, node, player, pointed) end, - after_place_node = pipeworks.after_place, - after_dig_node = pipeworks.after_dig, - on_rotate = false, + on_rotate = false, on_blast = function(pos, intensity) if not intensity or intensity > 1 + 3^0.5 then minetest.remove_node(pos) return {string.format("%s_%s", name, dropname)} end minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) - pipeworks.scan_for_tube_objects(pos) end, check_for_pole = pipeworks.check_for_vert_tube, check_for_horiz_pole = pipeworks.check_for_horiz_tube, tubenumber = tonumber(tname) } - if style == "6d" then - nodedef.paramtype2 = "facedir" - end if special == nil then special = {} end @@ -169,10 +129,12 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e end end - minetest.register_node(rname, nodedef) + local rname = string.format("%s_%s", name, tname) + core.register_alias(rname, name) + if not core.registered_nodes[name] then core.register_node(name, nodedef) end end -local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv, special, old_registration) +local register_all_tubes = function(name, desc, plain, _, _, _, inv, special, old_registration) if old_registration then for xm = 0, 1 do for xp = 0, 1 do @@ -200,7 +162,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv, connects[#connects+1] = 6 end local tname = xm..xp..ym..yp..zm..zp - register_one_tube(name, tname, "000000", desc, plain, noctrs, ends, short, inv, special, connects, "old") + register_one_tube(name, tname, "000000", desc, plain, nil, nil, nil, inv, special, connects, "old") end end end @@ -212,7 +174,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv, -- 6d tubes: uses only 10 nodes instead of 64, but the textures must be rotated local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}} for index, connects in ipairs(cconnects) do - register_one_tube(name, tostring(index), "1", desc, plain, noctrs, ends, short, inv, special, connects, "6d") + register_one_tube(name, tostring(index), "1", desc, plain, nil, nil, nil, inv, special, connects, "6d") end if REGISTER_COMPATIBILITY then local cname = name.."_compatibility" @@ -225,8 +187,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv, paramtype = "light", sunlight_propagates = true, description = S("Pneumatic tube segment (legacy)"), - after_place_node = pipeworks.after_place, - groups = {not_in_creative_inventory = 1, tube_to_update = 1, tube = 1}, + groups = {not_in_creative_inventory = 1, tube_to_update = 1, tube = 1}, is_ground_content = false, tube = {connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}}, drop = name.."_1", @@ -254,7 +215,7 @@ end pipeworks.register_tube = function(name, def, ...) if type(def) == "table" then register_all_tubes(name, def.description, - def.plain, def.noctr, def.ends, def.short, + def.plain, nil, nil, nil, def.inventory_image, def.node_def, def.no_facedir) else -- we assert to be the old function with the second parameter being the description @@ -263,19 +224,3 @@ pipeworks.register_tube = function(name, def, ...) register_all_tubes(name, def, ...) end end - - -if REGISTER_COMPATIBILITY then - minetest.register_abm({ - nodenames = {"group:tube_to_update"}, - interval = 1, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - local minp = vector.subtract(pos, 1) - local maxp = vector.add(pos, 1) - if table.getn(minetest.find_nodes_in_area(minp, maxp, "ignore")) == 0 then - pipeworks.scan_for_tube_objects(pos) - end - end - }) -end diff --git a/tubes/routing.lua b/tubes/routing.lua index e0a90aa8..f284bc01 100644 --- a/tubes/routing.lua +++ b/tubes/routing.lua @@ -92,7 +92,6 @@ pipeworks.register_tube("pipeworks:broken_tube", { nodedef.tube.on_repair(pos, was_node) else minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 }) - pipeworks.scan_for_tube_objects(pos) end meta:set_string("the_tube_was", "") else @@ -165,8 +164,14 @@ local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes and "clip" or true if pipeworks.enable_one_way_tube then - local tiles = {"pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_output.png", - "pipeworks_one_way_tube_input.png", "pipeworks_one_way_tube_side.png", "pipeworks_one_way_tube_top.png"} + local tiles = { + "pipeworks_one_way_tube.png", + "pipeworks_one_way_tube.png^[transformR180", + "pipeworks_one_way_tube_port.png", + "pipeworks_one_way_tube_port.png", + "pipeworks_one_way_tube.png^[transformR180", + "pipeworks_one_way_tube.png" + } for i, tile in ipairs(tiles) do tiles[i] = pipeworks.make_tube_tile(tile) end @@ -178,8 +183,13 @@ if pipeworks.enable_one_way_tube then drawtype = "nodebox", paramtype = "light", node_box = {type = "fixed", - fixed = {{-1/2, -9/64, -9/64, 1/2, 9/64, 9/64}}}, - groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, axey=1, handy=1, pickaxey=1}, + fixed = { + {-1/2, -9/64, -9/64, -9/64, 9/64, 9/64}, + {9/64, -9/64, -9/64, 1/2, 9/64, 9/64}, + {-13/64, -13/64, -13/64, 13/64, 13/64, 13/64} + } + }, + groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, tube = 1, axey=1, handy=1, pickaxey=1}, is_ground_content = false, _mcl_hardness=0.8, _sound_def = { @@ -196,9 +206,7 @@ if pipeworks.enable_one_way_tube then end, priority = 75 -- Higher than normal tubes, but lower than receivers }, - after_place_node = pipeworks.after_place, - after_dig_node = pipeworks.after_dig, - on_rotate = pipeworks.on_rotate, + connect_sides = {"left","right"}, check_for_pole = pipeworks.check_for_vert_tube, check_for_horiz_pole = pipeworks.check_for_horiz_tube }) diff --git a/tubes/sorting.lua b/tubes/sorting.lua index 39a86867..16a5ca19 100644 --- a/tubes/sorting.lua +++ b/tubes/sorting.lua @@ -132,7 +132,6 @@ if pipeworks.enable_mese_tube then end update_formspec(pos) end - return pipeworks.after_place(pos, placer, itemstack, pointed_thing) end, on_punch = update_formspec, on_receive_fields = function(pos, formname, fields, sender) diff --git a/tubes/tags.lua b/tubes/tags.lua index ffd7ec7f..450764cf 100644 --- a/tubes/tags.lua +++ b/tubes/tags.lua @@ -112,7 +112,6 @@ pipeworks.register_tube("pipeworks:tag_tube", { end update_formspec(pos) end - return pipeworks.after_place(pos, placer, itemstack, pointed_thing) end, on_receive_fields = function(pos, formname, fields, sender) if (fields.quit and not fields.key_enter_field) diff --git a/tubes/teleport.lua b/tubes/teleport.lua index 83d9344a..6d9b9554 100644 --- a/tubes/teleport.lua +++ b/tubes/teleport.lua @@ -263,7 +263,6 @@ end local function repair_tube(pos, node) minetest.swap_node(pos, {name = node.name, param2 = node.param2}) - pipeworks.scan_for_tube_objects(pos) local meta = minetest.get_meta(pos) local channel = meta:get_string("channel") if channel ~= "" then @@ -316,7 +315,6 @@ if has_digilines then def.after_place_node = function(pos, placer) -- Set owner for digilines minetest.get_meta(pos):set_string("owner", placer:get_player_name()) - pipeworks.after_place(pos) end def.digiline = { receptor = { diff --git a/tubes/vacuum.lua b/tubes/vacuum.lua index d78d8377..b545b033 100644 --- a/tubes/vacuum.lua +++ b/tubes/vacuum.lua @@ -36,7 +36,6 @@ end local function repair_tube(pos, was_node) minetest.swap_node(pos, {name = was_node.name, param2 = was_node.param2}) - pipeworks.scan_for_tube_objects(pos) set_timer(pos) end diff --git a/wielder.lua b/wielder.lua index 0850e5a7..a5a3ed62 100644 --- a/wielder.lua +++ b/wielder.lua @@ -123,6 +123,10 @@ function pipeworks.register_wielder(def) axey = 1, handy = 1, pickaxey = 1, not_in_creative_inventory = state == "on" and 1 or nil } + local connect_sides = {} + for k, _ in ipairs(def.connect_sides) do + table.insert(connect_sides, k) + end minetest.register_node(def.name.."_"..state, { description = def.description, tiles = def.tiles[state], @@ -175,6 +179,7 @@ function pipeworks.register_wielder(def) return stack:get_count() end, }, + connect_sides = connect_sides, on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -185,7 +190,6 @@ function pipeworks.register_wielder(def) set_wielder_formspec(def, meta) end, after_place_node = function(pos, placer) - pipeworks.scan_for_tube_objects(pos) if not placer then return end @@ -200,9 +204,7 @@ function pipeworks.register_wielder(def) minetest.add_item(pos, stack) end end - pipeworks.scan_for_tube_objects(pos) end, - on_rotate = pipeworks.on_rotate, allow_metadata_inventory_put = function(pos, listname, index, stack, player) if not pipeworks.may_configure(pos, player) then return 0 end return stack:get_count()