From e082ea473b2c9a50a6ab3c1cf70ca8f39f50ad5b Mon Sep 17 00:00:00 2001 From: OgelGames Date: Sun, 28 Nov 2021 14:40:40 +1100 Subject: [PATCH 01/40] fix missing argument when calling `on_rightclick` --- devices.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devices.lua b/devices.lua index 49875c8..6e6b6e4 100644 --- a/devices.lua +++ b/devices.lua @@ -28,7 +28,9 @@ function pipeworks.rotate_on_place(itemstack, placer, pointed_thing) if (not placer:get_player_control().sneak) and minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then - minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) + minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, + node, placer, itemstack, pointed_thing) + else local pitch = placer:get_look_pitch() From 8f067db7cd69fc05cc6e72fdd53b82de98f169ed Mon Sep 17 00:00:00 2001 From: OgelGames Date: Sun, 28 Nov 2021 16:13:11 +1100 Subject: [PATCH 02/40] github luacheck workflow --- .github/workflows/luacheck.yml | 13 +++++++++++++ .gitlab-ci.yml | 8 -------- 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/luacheck.yml delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/luacheck.yml b/.github/workflows/luacheck.yml new file mode 100644 index 0000000..a13efa9 --- /dev/null +++ b/.github/workflows/luacheck.yml @@ -0,0 +1,13 @@ +name: luacheck +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: apt + run: sudo apt-get install -y luarocks + - name: luacheck install + run: luarocks install --local luacheck + - name: luacheck run + run: $HOME/.luarocks/bin/luacheck ./ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index ff51e7e..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,8 +0,0 @@ -stages: - - test - -luacheck: - stage: test - image: pipelinecomponents/luacheck:latest - script: - - luacheck . From 23fe215721a816d49652f4523c9ff6458b010b4b Mon Sep 17 00:00:00 2001 From: sfence Date: Mon, 29 Nov 2021 17:01:16 +0100 Subject: [PATCH 03/40] Fix furnace block fuel (#2) * Fix blocking of fuel inventory by fuel replacement and losing of fuel replacements. --- compat-furnaces.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/compat-furnaces.lua b/compat-furnaces.lua index 1894056..797ecfd 100644 --- a/compat-furnaces.lua +++ b/compat-furnaces.lua @@ -189,8 +189,25 @@ local function furnace_node_timer(pos, elapsed) fuel_totaltime = 0 src_time = 0 else - -- Take fuel from fuel list - inv:set_stack("fuel", 1, afterfuel.items[1]) + -- prevent blocking of fuel inventory (for automatization mods) + local is_fuel = minetest.get_craft_result({method = "fuel", width = 1, items = {afterfuel.items[1]:to_string()}}) + if is_fuel.time == 0 then + table.insert(fuel.replacements, afterfuel.items[1]) + inv:set_stack("fuel", 1, "") + else + -- Take fuel from fuel list + inv:set_stack("fuel", 1, afterfuel.items[1]) + end + -- Put replacements in dst list or drop them on the furnace. + local replacements = fuel.replacements + if replacements[1] then + local leftover = inv:add_item("dst", replacements[1]) + if not leftover:is_empty() then + local above = vector.new(pos.x, pos.y + 1, pos.z) + local drop_pos = minetest.find_node_near(above, 1, {"air"}) or above + minetest.item_drop(replacements[1], nil, drop_pos) + end + end update = true fuel_totaltime = fuel.time + (fuel_time - fuel_totaltime) src_time = src_time + elapsed From a70115ab8dce5b0930dc4aef0a486f22d0ac40de Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Mon, 13 Dec 2021 20:20:47 -0500 Subject: [PATCH 04/40] update wiki link --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 8b74b76..4af070d 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ This mod uses nodeboxes to supply a complete set of 3D pipes and tubes, along devices that work with them. -See https://gitlab.com/VanessaE/pipeworks/wikis/ for detailed information about usage of this mod. +See https://github.com/mt-mods/pipeworks/wiki/ for detailed information about usage of this mod. Unlike the previous version of this mod, these pipes are rounded, and when placed, they'll automatically join together as needed. Pipes can go vertically From 7d3a61e595eee35dcedeea685744185deca5cbbb Mon Sep 17 00:00:00 2001 From: zichen <34205903+IFRFSX@users.noreply.github.com> Date: Sun, 26 Dec 2021 14:12:15 +0800 Subject: [PATCH 05/40] Fix toggling of autocrafter when `digilines` is not installed (#5) Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> --- autocrafter.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 8e3e779..2404188 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -277,8 +277,7 @@ minetest.register_node("pipeworks:autocrafter", { update_meta(meta, false) end, on_receive_fields = function(pos, formname, fields, sender) - if not fields.channel or (fields.quit and not fields.key_enter_field) - or not pipeworks.may_configure(pos, sender) then + if (fields.quit and not fields.key_enter_field) or not pipeworks.may_configure(pos, sender) then return end local meta = minetest.get_meta(pos) From 794cae675e3e065077239e0e14391067a8c48ae6 Mon Sep 17 00:00:00 2001 From: SX <50966843+S-S-X@users.noreply.github.com> Date: Sun, 2 Jan 2022 16:14:14 +0200 Subject: [PATCH 06/40] Expose set_tube on public API (#6) * Expose set_tube on public API * Added update_meta to public tptube API --- teleport_tube.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/teleport_tube.lua b/teleport_tube.lua index e812b70..c59f740 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -287,5 +287,7 @@ pipeworks.tptube = { hash = hash, save_tube_db = save_tube_db, get_db = function() return tp_tube_db or read_tube_db() end, + set_tube = set_tube, + update_meta = update_meta, tp_tube_db_version = tp_tube_db_version } From 06fd75421607c97c861cc4e9034b73e5f82af91f Mon Sep 17 00:00:00 2001 From: OgelGames Date: Fri, 7 Jan 2022 13:42:08 +1100 Subject: [PATCH 07/40] fix `pipeworks_enable_items_per_tube_limit` setting fixes #7 --- item_transport.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/item_transport.lua b/item_transport.lua index e1ee192..76fe538 100644 --- a/item_transport.lua +++ b/item_transport.lua @@ -1,5 +1,5 @@ local luaentity = pipeworks.luaentity -local enable_max_limit = minetest.settings:get("pipeworks_enable_items_per_tube_limit") +local enable_max_limit = minetest.settings:get_bool("pipeworks_enable_items_per_tube_limit") local max_tube_limit = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30 if enable_max_limit == nil then enable_max_limit = true end From 5618003be30951233ea575cca56789f6d32385f5 Mon Sep 17 00:00:00 2001 From: OgelGames Date: Mon, 7 Feb 2022 15:53:29 +1100 Subject: [PATCH 08/40] fix remaining `use_texture_alpha` warnings extension of d2954c52, using the same compatibility check for now, though it would be good to bump the minimum minetest version to 5.4 at some point fixes #11 --- devices.lua | 5 +++++ routing_tubes.lua | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/devices.lua b/devices.lua index 6e6b6e4..0acbc76 100644 --- a/devices.lua +++ b/devices.lua @@ -1,6 +1,8 @@ local S = minetest.get_translator("pipeworks") local new_flow_logic_register = pipeworks.flowables.register +local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes + local polys = "" if pipeworks.enable_lowpoly then polys = "_lowpoly" end @@ -142,6 +144,7 @@ for s in ipairs(states) do drawtype = "mesh", mesh = "pipeworks_pump"..polys..".obj", tiles = { "pipeworks_pump_"..states[s]..".png" }, + use_texture_alpha = texture_alpha_mode and "clip" or true, paramtype = "light", paramtype2 = "facedir", groups = dgroups, @@ -286,6 +289,7 @@ minetest.register_node("pipeworks:grating", { "pipeworks_grating_sides.png", "pipeworks_grating_sides.png" }, + use_texture_alpha = texture_alpha_mode and "clip" or true, drawtype = "nodebox", node_box = { type = "fixed", @@ -357,6 +361,7 @@ minetest.register_node(nodename_spigot_loaded, { }, { name = "pipeworks_spigot.png" } }, + use_texture_alpha = texture_alpha_mode and "blend" or true, sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", diff --git a/routing_tubes.lua b/routing_tubes.lua index e7bc596..a99d1c3 100644 --- a/routing_tubes.lua +++ b/routing_tubes.lua @@ -163,11 +163,15 @@ if pipeworks.enable_crossing_tube then }) end +local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes + and "clip" or true + if pipeworks.enable_one_way_tube then minetest.register_node("pipeworks:one_way_tube", { description = S("One way tube"), 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"}, + use_texture_alpha = texture_alpha_mode, paramtype2 = "facedir", drawtype = "nodebox", paramtype = "light", From 5aa0501872c618171dc58ade1d75f0db989f3bd4 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Mon, 14 Mar 2022 21:39:58 -0400 Subject: [PATCH 09/40] make pipeworks Game agnostic (#16) * make it boot in non mtg * make water flow * fix water texture warnings * fix missing steel texture issues * remove depreciated/unnessary default function calls * make sounds work * fix default formspec crashes * fix wierd tab spacing * additionally game dig group support * move crafts to crafts.lua * make crafts support various games --- autocrafter.lua | 15 +- common.lua | 2 +- crafts.lua | 369 ++++++++++++++++++++++++++++++++++------ decorative_tubes.lua | 40 ++--- devices.lua | 110 +++++++----- filter-injector.lua | 33 +--- flowing_logic.lua | 16 +- init.lua | 18 +- legacy.lua | 4 +- lua_tube.lua | 12 +- mod.conf | 4 +- pipes.lua | 14 +- pressure_logic/abms.lua | 8 +- routing_tubes.lua | 36 +--- signal_tubes.lua | 4 +- sorting_tubes.lua | 21 --- teleport_tube.lua | 12 +- trashcan.lua | 15 +- tube_registration.lua | 8 +- vacuum_tubes.lua | 25 +-- wielder.lua | 28 +-- 21 files changed, 466 insertions(+), 328 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 2404188..7ec4436 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -179,10 +179,6 @@ local function update_meta(meta, enabled) "image_button[3,2;1,0.6;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" .. "list[context;src;0,4.5;8,3;]".. "list[context;dst;4,0;4,3;]".. - default.gui_bg.. - default.gui_bg_img.. - default.gui_slots.. - default.get_hotbar_bg(0,8) .. "list[current_player;main;0,8;8,4;]" .. "listring[current_player;main]".. "listring[context;src]" .. @@ -252,7 +248,7 @@ minetest.register_node("pipeworks:autocrafter", { description = S("Autocrafter"), drawtype = "normal", tiles = {"pipeworks_autocrafter.png"}, - groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1}, + groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 1}, tube = {insert_object = function(pos, node, stack, direction) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -428,12 +424,3 @@ minetest.register_node("pipeworks:autocrafter", { }, }) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:autocrafter" - -minetest.register_craft( { - output = "pipeworks:autocrafter 2", - recipe = { - { "default:steel_ingot", "default:mese_crystal", "default:steel_ingot" }, - { "basic_materials:plastic_sheet", "default:steel_ingot", "basic_materials:plastic_sheet" }, - { "default:steel_ingot", "default:mese_crystal", "default:steel_ingot" } - }, -}) diff --git a/common.lua b/common.lua index 207b728..3d40491 100644 --- a/common.lua +++ b/common.lua @@ -183,7 +183,7 @@ function pipeworks.create_fake_player(def, is_dynamic) is_player = delay(true), is_fake_player = true, - _formspec = def.formspec or default.gui_survival_form, + _formspec = def.formspec or "", _hp = def.hp or 20, _breath = 11, _pos = def.position and table.copy(def.position) or vector.new(), diff --git a/crafts.lua b/crafts.lua index 9c02da8..178cfc2 100644 --- a/crafts.lua +++ b/crafts.lua @@ -1,87 +1,348 @@ +local materials = { + stone = "default:stone", + desert_stone = "default:desert_stone", + desert_sand = "default:desert_sand", + chest = "default:chest", + copper_ingot = "default:copper_ingot", + steel_ingot = "default:steel_ingot", + gold_ingot = "default:gold_ingot", + mese = "default:mese", + mese_crystal = "default:mese_crystal", + mese_crystal_fragment = "default:mese_crystal_fragment", + glass = "default:glass", +} + +if minetest.get_modpath("mcl_core") then + materials = { + stone = "mcl_core:stone", + desert_stone = "mcl_core:sandstone2", + desert_sand = "mcl_core:sand", + chest = "mcl_chests:chest_small", + steel_ingot = "mcl_core:iron_ingot", + gold_ingot = "mcl_core:gold_ingot", + mese = "default:mese", + mese_crystal = "default:mese_crystal", + mese_crystal_fragment = "mesecons:redstone", + -- Use iron where no equivalent + copper_ingot = "mcl_core:iron_ingot", + glass = "default:glass", + } +elseif minetest.get_modpath("fl_ores") and minetest.get_modpath("fl_stone") then + materials = { + stone = "fl_stone:stone", + desert_stone = "fl_stone:desert_stone", + desert_sand = "fl_stone:desert_sand", + chest = "fl_storage:wood_chest", + steel_ingot = "fl_ores:iron_ingot", + gold_ingot = "fl_ores:gold_ingot", + mese = "fl_ores:iron_ingot", + mese_crystal = "fl_ores:iron_ingot", + mese_crystal_fragment = "fl_ores:iron_ingot", + copper_ingot = "fl_ores:copper_ingot", + glass = "fl_glass:framed_glass", + } +elseif minetest.get_modpath("hades_core") then + materials = { + stone = "hades_core:stone", + desert_stone = "hades_core:desert_stone", + desert_sand = "hades_core:desert_sand", + chest = "hades_core:chest"; + steel_ingot = "hades_core:steel_ingot", + gold_ingot = "hades_core:gold_ingot", + mese = "hades_core:mese", + mese_crystal = "hades_core:mese_crystal", + mese_crystal_fragment = "hades_core:mese_crystal_fragment", + copper_ingot = "hades_core:copper_ingot", + tin_ingot = "hades_core:tin_ingot", + glass = "default:glass", + } +end + -- Crafting recipes for pipes minetest.register_craft( { - output = "pipeworks:pipe_1_empty 12", - recipe = { - { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }, - { "", "", "" }, - { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" } - }, + output = "pipeworks:pipe_1_empty 12", + recipe = { + { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }, + { "", "", "" }, + { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot } + }, }) minetest.register_craft( { - output = "pipeworks:straight_pipe_empty 3", - recipe = { - { "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty" }, - }, + output = "pipeworks:straight_pipe_empty 3", + recipe = { + { "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty" }, + }, }) minetest.register_craft( { - output = "pipeworks:spigot 3", - recipe = { - { "pipeworks:pipe_1_empty", "" }, - { "", "pipeworks:pipe_1_empty" }, - }, + output = "pipeworks:spigot 3", + recipe = { + { "pipeworks:pipe_1_empty", "" }, + { "", "pipeworks:pipe_1_empty" }, + }, }) minetest.register_craft( { - output = "pipeworks:entry_panel_empty 2", - recipe = { - { "", "default:steel_ingot", "" }, - { "", "pipeworks:pipe_1_empty", "" }, - { "", "default:steel_ingot", "" }, - }, +output = "pipeworks:entry_panel_empty 2", +recipe = { + { "", materials.steel_ingot, "" }, + { "", "pipeworks:pipe_1_empty", "" }, + { "", materials.steel_ingot, "" }, +}, }) -- Various ancillary pipe devices minetest.register_craft( { - output = "pipeworks:pump_off 2", - recipe = { - { "default:stone", "default:steel_ingot", "default:stone" }, - { "default:copper_ingot", "default:mese_crystal_fragment", "default:copper_ingot" }, - { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" } - }, + output = "pipeworks:pump_off 2", + recipe = { + { materials.stone, materials.steel_ingot, materials.stone }, + { materials.copper_ingot, materials.mese_crystal_fragment, materials.copper_ingot }, + { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot } + }, }) minetest.register_craft( { - output = "pipeworks:valve_off_empty 2", - recipe = { - { "", "group:stick", "" }, - { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }, - { "", "default:steel_ingot", "" } - }, + output = "pipeworks:valve_off_empty 2", + recipe = { + { "", "group:stick", "" }, + { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }, + { "", materials.steel_ingot, "" } + }, }) minetest.register_craft( { - output = "pipeworks:storage_tank_0 2", - recipe = { - { "", "default:steel_ingot", "default:steel_ingot" }, - { "default:steel_ingot", "default:glass", "default:steel_ingot" }, - { "default:steel_ingot", "default:steel_ingot", "" } - }, + output = "pipeworks:storage_tank_0 2", + recipe = { + { "", materials.steel_ingot, materials.steel_ingot }, + { materials.steel_ingot, materials.glass, materials.steel_ingot }, + { materials.steel_ingot, materials.steel_ingot, "" } + }, }) minetest.register_craft( { - output = "pipeworks:grating 2", - recipe = { - { "default:steel_ingot", "", "default:steel_ingot" }, - { "", "pipeworks:pipe_1_empty", "" }, - { "default:steel_ingot", "", "default:steel_ingot" } - }, + output = "pipeworks:grating 2", + recipe = { + { materials.steel_ingot, "", materials.steel_ingot }, + { "", "pipeworks:pipe_1_empty", "" }, + { materials.steel_ingot, "", materials.steel_ingot } + }, }) minetest.register_craft( { - output = "pipeworks:flow_sensor_empty 2", - recipe = { - { "pipeworks:pipe_1_empty", "mesecons:mesecon", "pipeworks:pipe_1_empty" }, - }, + output = "pipeworks:flow_sensor_empty 2", + recipe = { + { "pipeworks:pipe_1_empty", "mesecons:mesecon", "pipeworks:pipe_1_empty" }, + }, }) minetest.register_craft( { - output = "pipeworks:fountainhead 2", - recipe = { - { "pipeworks:pipe_1_empty" }, - { "pipeworks:pipe_1_empty" } - }, + output = "pipeworks:fountainhead 2", + recipe = { + { "pipeworks:pipe_1_empty" }, + { "pipeworks:pipe_1_empty" } + }, }) + +-- injectors + +minetest.register_craft( { + output = "pipeworks:filter 2", + recipe = { + { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }, + { "group:stick", materials.mese_crystal, "basic_materials:plastic_sheet" }, + { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" } + }, +}) + +minetest.register_craft( { + output = "pipeworks:mese_filter 2", + recipe = { + { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }, + { "group:stick", materials.mese, "basic_materials:plastic_sheet" }, + { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" } + }, +}) + +if minetest.get_modpath("digilines") then + minetest.register_craft( { + output = "pipeworks:digiline_filter 2", + recipe = { + { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }, + { "group:stick", "digilines:wire_std_00000000", "basic_materials:plastic_sheet" }, + { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" } + }, + }) +end + +-- other + +minetest.register_craft( { + output = "pipeworks:autocrafter 2", + recipe = { + { materials.steel_ingot, materials.mese_crystal, materials.steel_ingot }, + { "basic_materials:plastic_sheet", materials.steel_ingot, "basic_materials:plastic_sheet" }, + { materials.steel_ingot, materials.mese_crystal, materials.steel_ingot } + }, +}) + +minetest.register_craft( { + output = "pipeworks:steel_block_embedded_tube 1", + recipe = { + { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }, + { materials.steel_ingot, "pipeworks:tube_1", materials.steel_ingot }, + { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot } + }, +}) + +minetest.register_craft( { + output = "pipeworks:steel_pane_embedded_tube 1", + recipe = { + { "", materials.steel_ingot, "" }, + { "", "pipeworks:tube_1", "" }, + { "", materials.steel_ingot, "" } + }, +}) + +minetest.register_craft({ + output = "pipeworks:trashcan", + recipe = { + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, + { materials.steel_ingot, "", materials.steel_ingot }, + { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }, + }, +}) + +minetest.register_craft( { + output = "pipeworks:teleport_tube_1 2", + recipe = { + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, + { materials.desert_stone, materials.mese, materials.desert_stone }, + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } + }, +}) + +if pipeworks.enable_priority_tube then + minetest.register_craft( { + output = "pipeworks:priority_tube_1 6", + recipe = { + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, + { materials.gold_ingot, "", materials.gold_ingot }, + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } + }, + }) +end + +if pipeworks.enable_accelerator_tube then + minetest.register_craft( { + output = "pipeworks:accelerator_tube_1 2", + recipe = { + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, + { materials.mese_crystal_fragment, materials.steel_ingot, materials.mese_crystal_fragment }, + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } + }, + }) +end + +if pipeworks.enable_crossing_tube then + minetest.register_craft( { + output = "pipeworks:crossing_tube_1 5", + recipe = { + { "", "pipeworks:tube_1", "" }, + { "pipeworks:tube_1", "pipeworks:tube_1", "pipeworks:tube_1" }, + { "", "pipeworks:tube_1", "" } + }, + }) +end + +if pipeworks.enable_one_way_tube then + minetest.register_craft({ + output = "pipeworks:one_way_tube 2", + recipe = { + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, + { "group:stick", materials.mese_crystal, "basic_materials:plastic_sheet" }, + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } + }, + }) +end + +if pipeworks.enable_mese_tube then + minetest.register_craft( { + output = "pipeworks:mese_tube_000000 2", + recipe = { + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, + { "", materials.mese_crystal, "" }, + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } + }, + }) + + minetest.register_craft( { + type = "shapeless", + output = "pipeworks:mese_tube_000000", + recipe = { + "pipeworks:tube_1", + materials.mese_crystal, + materials.mese_crystal, + materials.mese_crystal, + materials.mese_crystal, + }, + }) +end + +if pipeworks.enable_mese_sand_tube then + minetest.register_craft( { + output = "pipeworks:mese_sand_tube_1 2", + recipe = { + {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, + {"group:sand", materials.mese_crystal, "group:sand" }, + {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } + }, + }) + + minetest.register_craft( { + type = "shapeless", + output = "pipeworks:mese_sand_tube_1", + recipe = { + "pipeworks:sand_tube_1", + materials.mese_crystal_fragment, + materials.mese_crystal_fragment, + materials.mese_crystal_fragment, + materials.mese_crystal_fragment, + }, + }) +end + +if pipeworks.enable_deployer then + minetest.register_craft({ + output = "pipeworks:deployer_off", + recipe = { + { "group:wood", "default:chest", "group:wood" }, + { materials.stone, "mesecons:piston", materials.stone }, + { materials.stone, "mesecons:mesecon", materials.stone }, + } + }) +end + +if pipeworks.enable_dispenser then + minetest.register_craft({ + output = "pipeworks:dispenser_off", + recipe = { + { materials.desert_sand, materials.chest, materials.desert_sand }, + { materials.stone, "mesecons:piston", materials.stone }, + { materials.stone, "mesecons:mesecon", materials.stone }, + } + }) +end + +if pipeworks.enable_node_breaker then + minetest.register_craft({ + output = "pipeworks:nodebreaker_off", + recipe = { + { "basic_materials:gear_steel", "basic_materials:gear_steel", "basic_materials:gear_steel" }, + { materials.stone, "mesecons:piston", materials.stone }, + { "group:wood", "mesecons:mesecon", "group:wood" }, + } + }) +end \ No newline at end of file diff --git a/decorative_tubes.lua b/decorative_tubes.lua index 308330b..d79f8af 100644 --- a/decorative_tubes.lua +++ b/decorative_tubes.lua @@ -1,20 +1,24 @@ local S = minetest.get_translator("pipeworks") local straight = function(pos, node, velocity, stack) return {velocity} end +local steel_tex = "[combine:16x16^[noalpha^[colorize:#D3D3D3" +if minetest.get_modpath("default") then steel_tex = "default_steel_block.png" end minetest.register_node("pipeworks:steel_block_embedded_tube", { description = S("Airtight steelblock embedded tube"), tiles = { - "default_steel_block.png", "default_steel_block.png", - "default_steel_block.png", "default_steel_block.png", - "default_steel_block.png^pipeworks_tube_connection_metallic.png", - "default_steel_block.png^pipeworks_tube_connection_metallic.png", + steel_tex, steel_tex, + steel_tex, steel_tex, + steel_tex .. "^pipeworks_tube_connection_metallic.png", + steel_tex .. "^pipeworks_tube_connection_metallic.png", }, paramtype = "light", paramtype2 = "facedir", - groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1}, + groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2}, legacy_facedir_simple = true, - sounds = default.node_sound_stone_defaults(), + _sound_def = { + key = "node_sound_stone_defaults", + }, tube = { connect_sides = {front = 1, back = 1,}, priority = 50, @@ -30,15 +34,6 @@ minetest.register_node("pipeworks:steel_block_embedded_tube", { }) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:steel_block_embedded_tube" -minetest.register_craft( { - output = "pipeworks:steel_block_embedded_tube 1", - recipe = { - { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }, - { "default:steel_ingot", "pipeworks:tube_1", "default:steel_ingot" }, - { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" } - }, -}) - local pane_box = { type = "fixed", fixed = { @@ -66,9 +61,11 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", { collision_box = pane_box, paramtype = "light", paramtype2 = "facedir", - groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1}, + groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2}, legacy_facedir_simple = true, - sounds = default.node_sound_stone_defaults(), + _sound_def = { + key = "node_sound_stone_defaults", + }, tube = { connect_sides = {front = 1, back = 1,}, priority = 50, @@ -83,12 +80,3 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", { on_rotate = pipeworks.on_rotate, }) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:steel_pane_embedded_tube" - -minetest.register_craft( { - output = "pipeworks:steel_pane_embedded_tube 1", - recipe = { - { "", "default:steel_ingot", "" }, - { "", "pipeworks:tube_1", "" }, - { "", "default:steel_ingot", "" } - }, -}) diff --git a/devices.lua b/devices.lua index 0acbc76..d6bfced 100644 --- a/devices.lua +++ b/devices.lua @@ -133,9 +133,9 @@ for s in ipairs(states) do local dgroups if states[s] == "off" then - dgroups = {snappy=3, pipe=1} + dgroups = {snappy=3, pipe=1, dig_generic = 4} else - dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1} + dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4} end local pumpname = "pipeworks:pump_"..states[s] @@ -148,7 +148,9 @@ for s in ipairs(states) do paramtype = "light", paramtype2 = "facedir", groups = dgroups, - sounds = default.node_sound_metal_defaults(), + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, pipe_connections = { top = 1 }, after_place_node = function(pos) @@ -170,7 +172,7 @@ for s in ipairs(states) do local fdir = node.param2 minetest.swap_node(pos, { name = "pipeworks:pump_"..states[3-s], param2 = fdir }) end, - on_rotate = screwdriver.rotate_simple + on_rotate = screwdriver and screwdriver.rotate_simple or nil }) -- FIXME: this currently assumes that pumps can only rotate around the fixed axis pointing Y+. @@ -200,7 +202,9 @@ for s in ipairs(states) do fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } }, groups = dgroups, - sounds = default.node_sound_metal_defaults(), + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -247,8 +251,10 @@ minetest.register_node(nodename_valve_loaded, { type = "fixed", fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } }, - groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -297,8 +303,10 @@ minetest.register_node("pipeworks:grating", { }, sunlight_propagates = true, paramtype = "light", - groups = {snappy=3, pipe=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, pipe_connections = { top = 1 }, after_place_node = function(pos) @@ -322,8 +330,10 @@ minetest.register_node(nodename_spigot_empty, { sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, pipe_connections = { left=1, right=1, front=1, back=1, left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 }, @@ -350,23 +360,17 @@ minetest.register_node(nodename_spigot_loaded, { drawtype = "mesh", mesh = "pipeworks_spigot_pouring"..polys..".obj", tiles = { - { - name = "default_water_flowing_animated.png", - animation = { - type = "vertical_frames", - aspect_w = 16, - aspect_h = 16, - length = 0.8, - }, - }, + minetest.registered_nodes[pipeworks.liquids.water.source].tiles[1], { name = "pipeworks_spigot.png" } }, use_texture_alpha = texture_alpha_mode and "blend" or true, sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, pipe_connections = { left=1, right=1, front=1, back=1, left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 }, @@ -421,8 +425,10 @@ minetest.register_node(nodename_panel_empty, { tiles = { "pipeworks_entry_panel.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -441,8 +447,10 @@ minetest.register_node(nodename_panel_loaded, { tiles = { "pipeworks_entry_panel.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -471,8 +479,10 @@ minetest.register_node(nodename_sensor_empty, { sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -510,8 +520,10 @@ minetest.register_node(nodename_sensor_loaded, { sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -555,12 +567,12 @@ new_flow_logic_register.transition_simple_set(sensor_pressure_set, { mesecons=pi -- TODO flow-logic-stub: these don't currently do anything under the new flow logic. for fill = 0, 10 do local filldesc=S("empty") - local sgroups = {snappy=3, pipe=1, tankfill=fill+1} + local sgroups = {snappy=3, pipe=1, tankfill=fill+1, dig_generic = 4} local image = nil if fill ~= 0 then filldesc=S("@1% full", 10*fill) - sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1} + sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4} image = "pipeworks_storage_tank_fittings.png" end @@ -577,8 +589,10 @@ for fill = 0, 10 do inventory_image = image, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, drop = "pipeworks:storage_tank_0", pipe_connections = { top = 1, bottom = 1}, @@ -606,7 +620,9 @@ for fill = 0, 10 do paramtype = "light", paramtype2 = "facedir", groups = sgroups, - sounds = default.node_sound_metal_defaults(), + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, drop = "pipeworks:storage_tank_0", pipe_connections = { top = 1, bottom = 1}, @@ -632,8 +648,10 @@ minetest.register_node(nodename_fountain_empty, { tiles = { "pipeworks_fountainhead.png" }, sunlight_propagates = true, paramtype = "light", - groups = {snappy=3, pipe=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, pipe_connections = { bottom = 1 }, after_place_node = function(pos) @@ -667,8 +685,10 @@ minetest.register_node(nodename_fountain_loaded, { tiles = { "pipeworks_fountainhead.png" }, sunlight_propagates = true, paramtype = "light", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, pipe_connections = { bottom = 1 }, after_place_node = function(pos) @@ -717,8 +737,10 @@ minetest.register_node(nodename_sp_empty, { tiles = { "pipeworks_straight_pipe_empty.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) @@ -739,8 +761,10 @@ minetest.register_node(nodename_sp_loaded, { tiles = { "pipeworks_straight_pipe_loaded.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, - sounds = default.node_sound_metal_defaults(), + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, on_place = pipeworks.rotate_on_place, after_dig_node = function(pos) diff --git a/filter-injector.lua b/filter-injector.lua index 5ae3719..a155307 100644 --- a/filter-injector.lua +++ b/filter-injector.lua @@ -377,7 +377,9 @@ for _, data in ipairs({ paramtype2 = "facedir", groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2}, legacy_facedir_simple = true, - sounds = default.node_sound_wood_defaults(), + _sound_def = { + key = "node_sound_wood_defaults", + }, on_construct = function(pos) local meta = minetest.get_meta(pos) set_filter_formspec(data, meta) @@ -482,35 +484,6 @@ for _, data in ipairs({ pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:"..data.name end -minetest.register_craft( { - output = "pipeworks:filter 2", - recipe = { - { "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" }, - { "group:stick", "default:mese_crystal", "basic_materials:plastic_sheet" }, - { "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" } - }, -}) - -minetest.register_craft( { - output = "pipeworks:mese_filter 2", - recipe = { - { "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" }, - { "group:stick", "default:mese", "basic_materials:plastic_sheet" }, - { "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" } - }, -}) - -if minetest.get_modpath("digilines") then - minetest.register_craft( { - output = "pipeworks:digiline_filter 2", - recipe = { - { "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" }, - { "group:stick", "digilines:wire_std_00000000", "basic_materials:plastic_sheet" }, - { "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" } - }, - }) -end - --[[ In the past the filter-injectors had real items in their inventories. This code puts them to the input to the filter-injector if possible. Else the items are diff --git a/flowing_logic.lua b/flowing_logic.lua index 55c3ac7..b1c12aa 100644 --- a/flowing_logic.lua +++ b/flowing_logic.lua @@ -83,7 +83,7 @@ end pipeworks.spigot_check = function(pos, node) local belowname = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name - if belowname and (belowname == "air" or belowname == "default:water_flowing" or belowname == "default:water_source") then + if belowname and (belowname == "air" or belowname == pipeworks.liquids.water.flowing or belowname == pipeworks.liquids.water.source) then local spigotname = minetest.get_node(pos).name local fdir=node.param2 % 4 local check = { @@ -96,14 +96,14 @@ pipeworks.spigot_check = function(pos, node) if near_node and string.find(near_node.name, "_loaded") then if spigotname and spigotname == "pipeworks:spigot" then minetest.add_node(pos,{name = "pipeworks:spigot_pouring", param2 = fdir}) - if finitewater or belowname ~= "default:water_source" then - minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name = "default:water_source"}) + if finitewater or belowname ~= pipeworks.liquids.water.source then + minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name = pipeworks.liquids.water.source}) end end else if spigotname == "pipeworks:spigot_pouring" then minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:spigot", param2 = fdir}) - if belowname == "default:water_source" and not finitewater then + if belowname == pipeworks.liquids.water.source and not finitewater then minetest.remove_node({x=pos.x,y=pos.y-1,z=pos.z}) end end @@ -113,20 +113,20 @@ end pipeworks.fountainhead_check = function(pos, node) local abovename = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name - if abovename and (abovename == "air" or abovename == "default:water_flowing" or abovename == "default:water_source") then + if abovename and (abovename == "air" or abovename == pipeworks.liquids.water.flowing or abovename == pipeworks.liquids.water.source) then local fountainhead_name = minetest.get_node(pos).name local near_node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}) if near_node and string.find(near_node.name, "_loaded") then if fountainhead_name and fountainhead_name == "pipeworks:fountainhead" then minetest.add_node(pos,{name = "pipeworks:fountainhead_pouring"}) - if finitewater or abovename ~= "default:water_source" then - minetest.add_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "default:water_source"}) + if finitewater or abovename ~= pipeworks.liquids.water.source then + minetest.add_node({x=pos.x,y=pos.y+1,z=pos.z},{name = pipeworks.liquids.water.source}) end end else if fountainhead_name == "pipeworks:fountainhead_pouring" then minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:fountainhead"}) - if abovename == "default:water_source" and not finitewater then + if abovename == pipeworks.liquids.water.source and not finitewater then minetest.remove_node({x=pos.x,y=pos.y+1,z=pos.z}) end end diff --git a/init.lua b/init.lua index beeefb7..8fb0b31 100644 --- a/init.lua +++ b/init.lua @@ -11,6 +11,16 @@ pipeworks.worldpath = minetest.get_worldpath() pipeworks.modpath = minetest.get_modpath("pipeworks") local S = minetest.get_translator("pipeworks") +pipeworks.liquids = {} +pipeworks.liquids.water = { + source = minetest.registered_nodes["mapgen_water_source"].name, + flowing = minetest.registered_nodes["mapgen_water_source"].liquid_alternative_flowing +} +pipeworks.liquids.river_water = { + source = minetest.registered_nodes["mapgen_river_water_source"].name, + flowing = minetest.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing +} + dofile(pipeworks.modpath.."/default_settings.lua") -- Read the external config file if it exists. local worldsettingspath = pipeworks.worldpath.."/pipeworks_settings.txt" @@ -40,7 +50,8 @@ pipeworks.rules_all = {{x=0, y=0, z=1},{x=0, y=0, z=-1},{x=1, y=0, z=0},{x=-1, y pipeworks.mesecons_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}} pipeworks.digilines_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}} -pipeworks.liquid_texture = "default_water.png" +pipeworks.liquid_texture = minetest.registered_nodes[pipeworks.liquids.water.flowing].tiles[1] +if type(pipeworks.liquid_texture) == "table" then pipeworks.liquid_texture = pipeworks.liquid_texture.name end pipeworks.button_off = {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"} pipeworks.button_on = {text="", texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"} @@ -113,7 +124,6 @@ dofile(pipeworks.modpath.."/autoplace_tubes.lua") dofile(pipeworks.modpath.."/luaentity.lua") dofile(pipeworks.modpath.."/item_transport.lua") dofile(pipeworks.modpath.."/flowing_logic.lua") -dofile(pipeworks.modpath.."/crafts.lua") dofile(pipeworks.modpath.."/tube_registration.lua") dofile(pipeworks.modpath.."/routing_tubes.lua") dofile(pipeworks.modpath.."/sorting_tubes.lua") @@ -137,7 +147,7 @@ dofile(pipeworks.modpath..logicdir.."flowable_node_registry_install.lua") if pipeworks.enable_pipes then dofile(pipeworks.modpath.."/pipes.lua") end if pipeworks.enable_teleport_tube then dofile(pipeworks.modpath.."/teleport_tube.lua") end if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end -if pipeworks.enable_redefines then +if pipeworks.enable_redefines and minetest.get_modpath("default") then dofile(pipeworks.modpath.."/compat-chests.lua") dofile(pipeworks.modpath.."/compat-furnaces.lua") end @@ -147,6 +157,8 @@ if pipeworks.enable_lua_tube and dofile(pipeworks.modpath.."/lua_tube.lua") end +dofile(pipeworks.modpath.."/crafts.lua") + minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty") -- Unified Inventory categories integration diff --git a/legacy.lua b/legacy.lua index 72f8cb4..a426a62 100644 --- a/legacy.lua +++ b/legacy.lua @@ -27,7 +27,9 @@ if not minetest.get_modpath("auto_tree_tap") and is_ground_content = true, paramtype2 = "facedir", groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1 }, - sounds = default.node_sound_stone_defaults(), + _sound_def = { + key = "node_sound_stone_defaults", + }, tube = {connect_sides={back=1}}, on_construct = function(pos) local meta = minetest.get_meta(pos) diff --git a/lua_tube.lua b/lua_tube.lua index c5fd24c..0898749 100644 --- a/lua_tube.lua +++ b/lua_tube.lua @@ -865,7 +865,7 @@ for white = 0, 1 do tiles[3] = tiles[3]..tiles_on_off.R270:format(white == 1 and "on" or "off"); tiles[4] = tiles[4]..tiles_on_off.R_90:format(white == 1 and "on" or "off"); - local groups = {snappy = 3, tube = 1, tubedevice = 1, overheat = 1} + local groups = {snappy = 3, tube = 1, tubedevice = 1, overheat = 1, dig_generic = 4} if red + blue + yellow + green + black + white ~= 0 then groups.not_in_creative_inventory = 1 end @@ -918,7 +918,9 @@ for white = 0, 1 do node_box = node_box, on_construct = reset_meta, on_receive_fields = on_receive_fields, - sounds = default.node_sound_wood_defaults(), + _sound_def = { + key = "node_sound_wood_defaults", + }, mesecons = mesecons, digiline = digiline, -- Virtual portstates are the ports that @@ -1021,14 +1023,16 @@ minetest.register_node(BASENAME .. "_burnt", { is_burnt = true, paramtype = "light", is_ground_content = false, - groups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory=1}, + groups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory=1, dig_generic = 4}, drop = BASENAME.."000000", sunlight_propagates = true, selection_box = selection_box, node_box = node_box, on_construct = reset_meta, on_receive_fields = on_receive_fields, - sounds = default.node_sound_wood_defaults(), + _sound_def = { + key = "node_sound_wood_defaults", + }, virtual_portstates = {red = false, blue = false, yellow = false, green = false, black = false, white = false}, mesecons = { diff --git a/mod.conf b/mod.conf index 17fd51c..c95a9c7 100644 --- a/mod.conf +++ b/mod.conf @@ -1,5 +1,5 @@ name = pipeworks description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them. -depends = default, basic_materials, screwdriver -optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory +depends = basic_materials +optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api min_minetest_version = 5.2.0 diff --git a/pipes.lua b/pipes.lua index befbbb9..5ab7c61 100644 --- a/pipes.lua +++ b/pipes.lua @@ -37,11 +37,11 @@ for index, connects in ipairs(cconnects) do end --]] - local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1} + local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4} local pipedesc = S("Pipe Segment").." "..dump(connects) if #connects == 0 then - pgroups = {snappy = 3, tube = 1} + pgroups = {snappy = 3, tube = 1, dig_generic = 4} pipedesc = S("Pipe Segment") end @@ -76,7 +76,9 @@ for index, connects in ipairs(cconnects) do fixed = outsel }, groups = pgroups, - sounds = default.node_sound_metal_defaults(), + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, drop = "pipeworks:pipe_1_empty", after_place_node = function(pos) @@ -91,7 +93,7 @@ for index, connects in ipairs(cconnects) do pipenumber = index }) - local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1} + local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4} minetest.register_node("pipeworks:pipe_"..index.."_loaded", { description = pipedesc, @@ -110,7 +112,9 @@ for index, connects in ipairs(cconnects) do fixed = outsel }, groups = pgroups, - sounds = default.node_sound_metal_defaults(), + _sound_def = { + key = "node_sound_metal_defaults", + }, walkable = true, drop = "pipeworks:pipe_1_empty", after_place_node = function(pos) diff --git a/pressure_logic/abms.lua b/pressure_logic/abms.lua index 50951b0..2675b7c 100644 --- a/pressure_logic/abms.lua +++ b/pressure_logic/abms.lua @@ -42,7 +42,7 @@ local check_for_liquids_v2 = function(pos, limit) for _, tpos in ipairs(coords) do if total >= limit then break end local name = minetest.get_node(tpos).name - if name == "default:water_source" then + if name == pipeworks.liquids.water.source then minetest.remove_node(tpos) total = total + 1 end @@ -247,9 +247,9 @@ flowlogic.helpers.make_neighbour_output_fixed = function(neighbours) -- in non-finite mode, pressure has to be sustained to keep the sources there. -- so in non-finite mode, placing water is dependent on the target node; -- draining pressure is not. - local canplace = (name == "air") or (name == "default:water_flowing") + local canplace = (name == "air") or (name == pipeworks.liquids.water.flowing) if canplace then - minetest.swap_node(npos, {name="default:water_source"}) + minetest.swap_node(npos, {name=pipeworks.liquids.water.source}) end if (not finitemode) or canplace then taken = taken + 1 @@ -268,7 +268,7 @@ flowlogic.helpers.make_neighbour_cleanup_fixed = function(neighbours) for _, offset in pairs(neighbours) do local npos = vector.add(pos, offset) local name = minetest.get_node(npos).name - if (name == "default:water_source") then + if (name == pipeworks.liquids.water.source) then --pipeworks.logger("neighbour_cleanup_fixed removing "..formatvec(npos)) minetest.remove_node(npos) end diff --git a/routing_tubes.lua b/routing_tubes.lua index a99d1c3..5e5fe0a 100644 --- a/routing_tubes.lua +++ b/routing_tubes.lua @@ -106,14 +106,6 @@ if pipeworks.enable_priority_tube then tube = { priority = 150 } -- higher than tubedevices (100) }, }) - minetest.register_craft( { - output = "pipeworks:priority_tube_1 6", - recipe = { - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, - { "default:gold_ingot", "", "default:gold_ingot" }, - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } - }, - }) end if pipeworks.enable_accelerator_tube then @@ -131,14 +123,6 @@ if pipeworks.enable_accelerator_tube then end} }, }) - minetest.register_craft( { - output = "pipeworks:accelerator_tube_1 2", - recipe = { - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, - { "default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment" }, - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } - }, - }) end if pipeworks.enable_crossing_tube then @@ -153,14 +137,6 @@ if pipeworks.enable_crossing_tube then tube = {can_go = function(pos, node, velocity, stack) return {velocity} end } }, }) - minetest.register_craft( { - output = "pipeworks:crossing_tube_1 5", - recipe = { - { "", "pipeworks:tube_1", "" }, - { "pipeworks:tube_1", "pipeworks:tube_1", "pipeworks:tube_1" }, - { "", "pipeworks:tube_1", "" } - }, - }) end local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes @@ -178,7 +154,9 @@ if pipeworks.enable_one_way_tube then 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}, - sounds = default.node_sound_wood_defaults(), + _sound_def = { + key = "node_sound_wood_defaults", + }, tube = { connect_sides = {left = 1, right = 1}, can_go = function(pos, node, velocity, stack) @@ -197,12 +175,4 @@ if pipeworks.enable_one_way_tube then check_for_horiz_pole = pipeworks.check_for_horiz_tube }) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:one_way_tube" - minetest.register_craft({ - output = "pipeworks:one_way_tube 2", - recipe = { - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, - { "group:stick", "default:mese_crystal", "basic_materials:plastic_sheet" }, - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } - }, - }) end diff --git a/signal_tubes.lua b/signal_tubes.lua index cabf488..2713507 100644 --- a/signal_tubes.lua +++ b/signal_tubes.lua @@ -11,7 +11,7 @@ local function after_break(pos) end end -if pipeworks.enable_detector_tube then +if minetest.get_modpath("mesecons") and pipeworks.enable_detector_tube then local detector_tube_step = 5 * tonumber(minetest.settings:get("dedicated_server_step")) pipeworks.register_tube("pipeworks:detector_tube_on", { description = S("Detecting Pneumatic Tube Segment on"), @@ -137,7 +137,7 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then }) end -if pipeworks.enable_conductor_tube then +if minetest.get_modpath("mesecons") and pipeworks.enable_conductor_tube then pipeworks.register_tube("pipeworks:conductor_tube_off", { description = S("Conducting Pneumatic Tube Segment"), inventory_image = "pipeworks_conductor_tube_inv.png", diff --git a/sorting_tubes.lua b/sorting_tubes.lua index 10a81a6..0168fad 100644 --- a/sorting_tubes.lua +++ b/sorting_tubes.lua @@ -163,25 +163,4 @@ if pipeworks.enable_mese_tube then end, }, }) - - minetest.register_craft( { - output = "pipeworks:mese_tube_000000 2", - recipe = { - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, - { "", "default:mese_crystal", "" }, - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } - }, - }) - - minetest.register_craft( { - type = "shapeless", - output = "pipeworks:mese_tube_000000", - recipe = { - "pipeworks:tube_1", - "default:mese_crystal_fragment", - "default:mese_crystal_fragment", - "default:mese_crystal_fragment", - "default:mese_crystal_fragment" - }, - }) end diff --git a/teleport_tube.lua b/teleport_tube.lua index c59f740..b41d525 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -153,9 +153,7 @@ local function update_meta(meta, can_receive) "label[7.0,0;"..S("Receive").."]".. "image_button[7.0,0.5;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]".. "button_exit[6.3,1.3;2,1;close;"..S("Close").."]".. - "label[0.2,2.3;"..itext.."]".. - default.gui_bg.. - default.gui_bg_img) + "label[0.2,2.3;"..itext.."]") end pipeworks.register_tube("pipeworks:teleport_tube", { @@ -262,14 +260,6 @@ pipeworks.register_tube("pipeworks:teleport_tube", { end }, }) -minetest.register_craft( { - output = "pipeworks:teleport_tube_1 2", - recipe = { - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, - { "default:desert_stone", "default:mese", "default:desert_stone" }, - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } - }, -}) if minetest.get_modpath("mesecons_mvps") ~= nil then mesecon.register_on_mvps_move(function(moved_nodes) diff --git a/trashcan.lua b/trashcan.lua index 361d73e..e106761 100644 --- a/trashcan.lua +++ b/trashcan.lua @@ -10,7 +10,7 @@ minetest.register_node("pipeworks:trashcan", { "pipeworks_trashcan_side.png", "pipeworks_trashcan_side.png", }, - groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1}, + groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 4}, tube = { insert_object = function(pos, node, stack, direction) return ItemStack("") @@ -25,10 +25,6 @@ minetest.register_node("pipeworks:trashcan", { "item_image[0,0;1,1;pipeworks:trashcan]".. "label[1,0;"..S("Trash Can").."]".. "list[context;trash;3.5,1;1,1;]".. - default.gui_bg.. - default.gui_bg_img.. - default.gui_slots.. - default.get_hotbar_bg(0,3) .. "list[current_player;main;0,3;8,4;]" .. "listring[]") meta:set_string("infotext", S("Trash Can")) @@ -41,12 +37,3 @@ minetest.register_node("pipeworks:trashcan", { end, }) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:trashcan" - -minetest.register_craft({ - output = "pipeworks:trashcan", - recipe = { - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, - { "default:steel_ingot", "", "default:steel_ingot" }, - { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }, - }, -}) diff --git a/tube_registration.lua b/tube_registration.lua index e1859f9..c621cd8 100644 --- a/tube_registration.lua +++ b/tube_registration.lua @@ -61,13 +61,13 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e outimgs[vti[v]] = ends[v] end - local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1} + local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1, dig_generic = 4} 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} + tgroups = {snappy = 3, tube = 1, tubedevice = 1, dig_generic = 4} tubedesc = desc iimg=inv outimgs = { @@ -102,7 +102,9 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e fixed = outboxes }, groups = tgroups, - sounds = default.node_sound_wood_defaults(), + _sound_def = { + key = "node_sound_wood_defaults", + }, walkable = true, stack_max = 99, basename = name, diff --git a/vacuum_tubes.lua b/vacuum_tubes.lua index 927480b..f6a3546 100644 --- a/vacuum_tubes.lua +++ b/vacuum_tubes.lua @@ -46,9 +46,7 @@ if pipeworks.enable_mese_sand_tube then "label[1.2,0.2;"..S("Adjustable Vacuuming Tube").."]".. "field[0.5,1.6;2.1,1;dist;"..S("Radius")..";${dist}]".. "button[2.3,1.3;1.5,1;set_dist;"..S("Set").."]".. - "button_exit[3.8,1.3;2,1;close;"..S("Close").."]".. - default.gui_bg.. - default.gui_bg_img) + "button_exit[3.8,1.3;2,1;close;"..S("Close").."]") meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment")) end, on_receive_fields = function(pos,formname,fields,sender) @@ -69,27 +67,6 @@ if pipeworks.enable_mese_sand_tube then end, }, }) - - minetest.register_craft( { - output = "pipeworks:mese_sand_tube_1 2", - recipe = { - {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, - {"group:sand", "default:mese_crystal", "group:sand" }, - {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } - }, - }) - - minetest.register_craft( { - type = "shapeless", - output = "pipeworks:mese_sand_tube_1", - recipe = { - "pipeworks:sand_tube_1", - "default:mese_crystal_fragment", - "default:mese_crystal_fragment", - "default:mese_crystal_fragment", - "default:mese_crystal_fragment" - }, - }) end local function vacuum(pos, radius) diff --git a/wielder.lua b/wielder.lua index 22df13f..92d121a 100644 --- a/wielder.lua +++ b/wielder.lua @@ -184,7 +184,9 @@ local function register_wielder(data) paramtype2 = "facedir", tubelike = 1, groups = groups, - sounds = default.node_sound_stone_defaults(), + _sound_def = { + key = "node_sound_stone_defaults", + }, drop = data.name_base.."_off", on_construct = function(pos) local meta = minetest.get_meta(pos) @@ -372,14 +374,6 @@ if pipeworks.enable_node_breaker then } register_wielder(data) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:nodebreaker_off" - minetest.register_craft({ - output = "pipeworks:nodebreaker_off", - recipe = { - { "basic_materials:gear_steel", "basic_materials:gear_steel", "basic_materials:gear_steel" }, - { "default:stone", "mesecons:piston", "default:stone" }, - { "group:wood", "mesecons:mesecon", "group:wood" }, - } - }) -- aliases for when someone had technic installed, but then uninstalled it but not pipeworks minetest.register_alias("technic:nodebreaker_off", "pipeworks:nodebreaker_off") minetest.register_alias("technic:nodebreaker_on", "pipeworks:nodebreaker_on") @@ -424,14 +418,6 @@ if pipeworks.enable_deployer then eject_drops = false, }) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:deployer_off" - minetest.register_craft({ - output = "pipeworks:deployer_off", - recipe = { - { "group:wood", "default:chest", "group:wood" }, - { "default:stone", "mesecons:piston", "default:stone" }, - { "default:stone", "mesecons:mesecon", "default:stone" }, - } - }) -- aliases for when someone had technic installed, but then uninstalled it but not pipeworks minetest.register_alias("technic:deployer_off", "pipeworks:deployer_off") minetest.register_alias("technic:deployer_on", "pipeworks:deployer_on") @@ -460,12 +446,4 @@ if pipeworks.enable_dispenser then eject_drops = false, }) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:dispenser_off" - minetest.register_craft({ - output = "pipeworks:dispenser_off", - recipe = { - { "default:desert_sand", "default:chest", "default:desert_sand" }, - { "default:stone", "mesecons:piston", "default:stone" }, - { "default:stone", "mesecons:mesecon", "default:stone" }, - } - }) end From 8a29f8844cd35235e04755ed50c6a3908c1c22f6 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Sun, 20 Mar 2022 12:47:45 -0400 Subject: [PATCH 10/40] fix pipeworks:mese_tube_000000 craft --- crafts.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crafts.lua b/crafts.lua index 178cfc2..ea44660 100644 --- a/crafts.lua +++ b/crafts.lua @@ -283,10 +283,10 @@ if pipeworks.enable_mese_tube then output = "pipeworks:mese_tube_000000", recipe = { "pipeworks:tube_1", - materials.mese_crystal, - materials.mese_crystal, - materials.mese_crystal, - materials.mese_crystal, + materials.mese_crystal_fragment, + materials.mese_crystal_fragment, + materials.mese_crystal_fragment, + materials.mese_crystal_fragment, }, }) end From 8e0b25fb2c69cd1deb15eef6191dbcb12a8fb93f Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Fri, 1 Apr 2022 19:50:21 -0400 Subject: [PATCH 11/40] fix https://github.com/mt-mods/pipeworks/issues/20 --- compat-furnaces.lua | 363 ++------------------------------------------ 1 file changed, 11 insertions(+), 352 deletions(-) diff --git a/compat-furnaces.lua b/compat-furnaces.lua index 797ecfd..28e642d 100644 --- a/compat-furnaces.lua +++ b/compat-furnaces.lua @@ -1,297 +1,22 @@ -- this file is basically a modified copy of -- minetest_game/mods/default/furnaces.lua --- translation support -local S = minetest.get_translator("pipeworks") -local DS = minetest.get_translator("default") - -local fs_helpers = pipeworks.fs_helpers +local def = table.copy(minetest.registered_nodes["default:furnace"]) +--local def_active = table.copy(minetest.registered_nodes["default:furnace_active"]) local tube_entry = "^pipeworks_tube_connection_stony.png" -local function active_formspec(fuel_percent, item_percent, pos, meta) - local formspec = - "size[8,8.5]".. - default.gui_bg.. - default.gui_bg_img.. - default.gui_slots.. - "list[current_name;src;2.75,0.5;1,1;]".. - "list[current_name;fuel;2.75,2.5;1,1;]".. - "image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:".. - (100-fuel_percent)..":default_furnace_fire_fg.png]".. - "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:".. - (item_percent)..":gui_furnace_arrow_fg.png^[transformR270]".. - "list[current_name;dst;4.75,0.96;2,2;]".. - "list[current_player;main;0,4.25;8,1;]".. - "list[current_player;main;0,5.5;8,3;8]".. - "listring[current_name;dst]".. - "listring[current_player;main]".. - "listring[current_name;src]".. - "listring[current_player;main]".. - "listring[current_name;fuel]".. - "listring[current_player;main]".. - default.get_hotbar_bg(0, 4.25) .. - fs_helpers.cycling_button( - meta, - "image_button[0,3.5;1,0.6", - "split_material_stacks", - { - pipeworks.button_off, - pipeworks.button_on - } - ).."label[0.9,3.51;"..S("Allow splitting incoming material (not fuel) stacks from tubes").."]" - return formspec -end - -local function inactive_formspec(pos, meta) - local formspec = "size[8,8.5]".. - default.gui_bg.. - default.gui_bg_img.. - default.gui_slots.. - "list[current_name;src;2.75,0.5;1,1;]".. - "list[current_name;fuel;2.75,2.5;1,1;]".. - "image[2.75,1.5;1,1;default_furnace_fire_bg.png]".. - "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]".. - "list[current_name;dst;4.75,0.96;2,2;]".. - "list[current_player;main;0,4.25;8,1;]".. - "list[current_player;main;0,5.5;8,3;8]".. - "listring[current_name;dst]".. - "listring[current_player;main]".. - "listring[current_name;src]".. - "listring[current_player;main]".. - "listring[current_name;fuel]".. - "listring[current_player;main]".. - default.get_hotbar_bg(0, 4.25) .. - fs_helpers.cycling_button( - meta, - "image_button[0,3.5;1,0.6", - "split_material_stacks", - { - pipeworks.button_off, - pipeworks.button_on - } - ).."label[0.9,3.51;"..S("Allow splitting incoming material (not fuel) stacks from tubes").."]" - return formspec -end - --- --- Node callback functions that are the same for active and inactive furnace --- - -local function can_dig(pos, player) - local meta = minetest.get_meta(pos); - local inv = meta:get_inventory() - return inv:is_empty("fuel") and inv:is_empty("dst") and inv:is_empty("src") -end - -local function allow_metadata_inventory_put(pos, listname, index, stack, player) - if minetest.is_protected(pos, player:get_player_name()) then - return 0 - end - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - if listname == "fuel" then - if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then - if inv:is_empty("src") then - meta:set_string("infotext", DS("Furnace is empty")) - end - return stack:get_count() - else - return 0 - end - elseif listname == "src" then - return stack:get_count() - elseif listname == "dst" then - return 0 - end -end - -local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local stack = inv:get_stack(from_list, from_index) - return allow_metadata_inventory_put(pos, to_list, to_index, stack, player) -end - -local function allow_metadata_inventory_take(pos, listname, index, stack, player) - if minetest.is_protected(pos, player:get_player_name()) then - return 0 - end - return stack:get_count() -end - -local function swap_node(pos, name) - local node = minetest.get_node(pos) - if node.name == name then - return - end - node.name = name - minetest.swap_node(pos, node) -end - -local function furnace_node_timer(pos, elapsed) - -- - -- Inizialize metadata - -- - local meta = minetest.get_meta(pos) - local fuel_time = meta:get_float("fuel_time") or 0 - local src_time = meta:get_float("src_time") or 0 - local fuel_totaltime = meta:get_float("fuel_totaltime") or 0 - - local inv = meta:get_inventory() - local srclist, fuellist - - local cookable, cooked - local fuel - - local update = true - while update do - update = false - - srclist = inv:get_list("src") - fuellist = inv:get_list("fuel") - - -- - -- Cooking - -- - - -- Check if we have cookable content - local aftercooked - cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) - cookable = cooked.time ~= 0 - - -- Check if we have enough fuel to burn - if fuel_time < fuel_totaltime then - -- The furnace is currently active and has enough fuel - fuel_time = fuel_time + elapsed - -- If there is a cookable item then check if it is ready yet - if cookable then - src_time = src_time + elapsed - if src_time >= cooked.time then - -- Place result in dst list if possible - if inv:room_for_item("dst", cooked.item) then - inv:add_item("dst", cooked.item) - inv:set_stack("src", 1, aftercooked.items[1]) - src_time = src_time - cooked.time - update = true - end - end - end - else - -- Furnace ran out of fuel - if cookable then - -- We need to get new fuel - local afterfuel - fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) - - if fuel.time == 0 then - -- No valid fuel in fuel list - fuel_totaltime = 0 - src_time = 0 - else - -- prevent blocking of fuel inventory (for automatization mods) - local is_fuel = minetest.get_craft_result({method = "fuel", width = 1, items = {afterfuel.items[1]:to_string()}}) - if is_fuel.time == 0 then - table.insert(fuel.replacements, afterfuel.items[1]) - inv:set_stack("fuel", 1, "") - else - -- Take fuel from fuel list - inv:set_stack("fuel", 1, afterfuel.items[1]) - end - -- Put replacements in dst list or drop them on the furnace. - local replacements = fuel.replacements - if replacements[1] then - local leftover = inv:add_item("dst", replacements[1]) - if not leftover:is_empty() then - local above = vector.new(pos.x, pos.y + 1, pos.z) - local drop_pos = minetest.find_node_near(above, 1, {"air"}) or above - minetest.item_drop(replacements[1], nil, drop_pos) - end - end - update = true - fuel_totaltime = fuel.time + (fuel_time - fuel_totaltime) - src_time = src_time + elapsed - end - else - -- We don't need to get new fuel since there is no cookable item - fuel_totaltime = 0 - src_time = 0 - end - fuel_time = 0 - end - - elapsed = 0 - end - - if fuel and fuel_totaltime > fuel.time then - fuel_totaltime = fuel.time - end - if srclist[1]:is_empty() then - src_time = 0 - end - - -- - -- Update formspec, infotext and node - -- - local formspec = inactive_formspec(pos, meta) - local item_state - local item_percent = 0 - if cookable then - item_percent = math.floor(src_time / cooked.time * 100) - if item_percent > 100 then - item_state = DS("100% (output full)") - else - item_state = DS("@1%", item_percent) - end - else - if srclist[1]:is_empty() then - item_state = DS("Empty") - else - item_state = DS("Not cookable") - end - end - - local fuel_state = DS("Empty") - local active = DS("Furnace inactive") - local result = false - - if fuel_totaltime ~= 0 then - active = DS("Furnace active") - local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100) - fuel_state = DS("@1%", fuel_percent) - formspec = active_formspec(fuel_percent, item_percent, pos, meta) - swap_node(pos, "default:furnace_active") - -- make sure timer restarts automatically - result = true - else - if not fuellist[1]:is_empty() then - fuel_state = DS("@1%", "0") - end - swap_node(pos, "default:furnace") - -- stop timer on the inactive furnace - minetest.get_node_timer(pos):stop() - end - - local infotext = active.." "..DS("(Item: @1; Fuel: @2)", item_state, fuel_state) - - -- - -- Set meta values - -- - meta:set_float("fuel_totaltime", fuel_totaltime) - meta:set_float("fuel_time", fuel_time) - meta:set_float("src_time", src_time) - meta:set_string("formspec", formspec) - meta:set_string("infotext", infotext) - - return result -end +local groups = table.copy(def.groups) +groups["tubedevice"] = 1 +groups["tubedevice_receiver"] = 1 +local groups_active = table.copy(groups) +groups_active["not_in_creative_inventory"] = 1 -- -- Node definitions -- -minetest.register_node(":default:furnace", { - description = DS("Furnace"), +minetest.override_item("default:furnace", { tiles = { "default_furnace_top.png"..tube_entry, "default_furnace_bottom.png"..tube_entry, @@ -300,7 +25,7 @@ minetest.register_node(":default:furnace", { "default_furnace_side.png"..tube_entry, "default_furnace_front.png" }, - groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1}, + groups = groups, tube = { insert_object = function(pos, node, stack, direction) local meta = minetest.get_meta(pos) @@ -330,57 +55,13 @@ minetest.register_node(":default:furnace", { input_inventory = "dst", connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1} }, - paramtype2 = "facedir", - legacy_facedir_simple = true, - is_ground_content = false, - sounds = default.node_sound_stone_defaults(), - can_dig = can_dig, - - on_timer = furnace_node_timer, - - on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", inactive_formspec(pos, meta)) - local inv = meta:get_inventory() - inv:set_size('src', 1) - inv:set_size('fuel', 1) - inv:set_size('dst', 4) - end, - - on_metadata_inventory_move = function(pos) - minetest.get_node_timer(pos):start(1.0) - end, - on_metadata_inventory_put = function(pos) - -- start timer function, it will sort out whether furnace can burn or not. - minetest.get_node_timer(pos):start(1.0) - end, - on_blast = function(pos) - local drops = {} - default.get_inventory_drops(pos, "src", drops) - default.get_inventory_drops(pos, "fuel", drops) - default.get_inventory_drops(pos, "dst", drops) - drops[#drops+1] = "default:furnace" - minetest.remove_node(pos) - return drops - end, - allow_metadata_inventory_put = allow_metadata_inventory_put, - allow_metadata_inventory_move = allow_metadata_inventory_move, - allow_metadata_inventory_take = allow_metadata_inventory_take, - on_receive_fields = function(pos, formname, fields, sender) - if not pipeworks.may_configure(pos, sender) then return end - fs_helpers.on_receive_fields(pos, fields) - local meta = minetest.get_meta(pos) - local formspec = inactive_formspec(pos, meta) - meta:set_string("formspec", formspec) - end, after_place_node = pipeworks.after_place, after_dig_node = pipeworks.after_dig, on_rotate = pipeworks.on_rotate }) -minetest.register_node(":default:furnace_active", { - description = DS("Furnace"), +minetest.override_item("default:furnace_active", { tiles = { "default_furnace_top.png"..tube_entry, "default_furnace_bottom.png"..tube_entry, @@ -398,7 +79,7 @@ minetest.register_node(":default:furnace_active", { }, } }, - groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1, not_in_creative_inventory = 1}, + groups = groups_active, tube = { insert_object = function(pos,node,stack,direction) local meta = minetest.get_meta(pos) @@ -419,35 +100,13 @@ minetest.register_node(":default:furnace_active", { if direction.y == 1 then return inv:room_for_item("fuel", stack) else - if meta:get_int("split_material_stacks") == 1 then - stack = stack:peek_item(1) - end return inv:room_for_item("src", stack) end end, input_inventory = "dst", connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1} }, - paramtype2 = "facedir", - light_source = 8, - drop = "default:furnace", - legacy_facedir_simple = true, - is_ground_content = false, - sounds = default.node_sound_stone_defaults(), - on_timer = furnace_node_timer, - can_dig = can_dig, - - allow_metadata_inventory_put = allow_metadata_inventory_put, - allow_metadata_inventory_move = allow_metadata_inventory_move, - allow_metadata_inventory_take = allow_metadata_inventory_take, - on_receive_fields = function(pos, formname, fields, sender) - if not pipeworks.may_configure(pos, sender) then return end - fs_helpers.on_receive_fields(pos, fields) - local meta = minetest.get_meta(pos) - local formspec = active_formspec(0, 0, pos, meta) - meta:set_string("formspec", formspec) - end, after_place_node = pipeworks.after_place, after_dig_node = pipeworks.after_dig, on_rotate = pipeworks.on_rotate From 96ccd29dd2e29459089f26e8df82f9e877d570a7 Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Fri, 1 Apr 2022 20:20:48 -0400 Subject: [PATCH 12/40] address flux review --- compat-furnaces.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat-furnaces.lua b/compat-furnaces.lua index 28e642d..776a526 100644 --- a/compat-furnaces.lua +++ b/compat-furnaces.lua @@ -6,7 +6,7 @@ local def = table.copy(minetest.registered_nodes["default:furnace"]) local tube_entry = "^pipeworks_tube_connection_stony.png" -local groups = table.copy(def.groups) +local groups = def.groups groups["tubedevice"] = 1 groups["tubedevice_receiver"] = 1 local groups_active = table.copy(groups) From 37eef736950f038e54fd74d11a5d905fb43abdad Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Sat, 16 Apr 2022 14:51:59 -0400 Subject: [PATCH 13/40] add I3 support + update to formspecs v2 (#22) * add fs helper inv function * add fs helper prepends function * add trash can, vacuum tube, teleport tube. wielders, autocrafter, mesetube, injectors * fixed missed texture to make game agnostic * fix luacheck --- .luacheckrc | 3 ++- autocrafter.lua | 50 +++++++++++++++++++++++++++++++++------------ common.lua | 49 ++++++++++++++++++++++++++++++++++++++++++++ filter-injector.lua | 35 +++++++++++++++++++++---------- mod.conf | 2 +- sorting_tubes.lua | 44 +++++++++++++++++++++++++-------------- teleport_tube.lua | 22 +++++++++++--------- trashcan.lua | 23 +++++++++++++++------ vacuum_tubes.lua | 4 +++- wielder.lua | 27 ++++++++++++++++++------ 10 files changed, 195 insertions(+), 64 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 85eba0b..494507e 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -19,6 +19,7 @@ read_globals = { -- mods "default", "mesecon", "digiline", - "screwdriver", "unified_inventory" + "screwdriver", "unified_inventory", + "i3", } diff --git a/autocrafter.lua b/autocrafter.lua index 7ec4436..60cfc2b 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -172,19 +172,43 @@ end local function update_meta(meta, enabled) local state = enabled and "on" or "off" meta:set_int("enabled", enabled and 1 or 0) - local fs = "size[8,12]".. - "list[context;recipe;0,0;3,3;]".. - "image[3,1;1,1;gui_hb_bg.png^[colorize:#141318:255]".. - "list[context;output;3,1;1,1;]".. - "image_button[3,2;1,0.6;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" .. - "list[context;src;0,4.5;8,3;]".. - "list[context;dst;4,0;4,3;]".. - "list[current_player;main;0,8;8,4;]" .. - "listring[current_player;main]".. - "listring[context;src]" .. - "listring[current_player;main]".. - "listring[context;dst]" .. - "listring[current_player;main]" + local list_backgrounds = "" + if minetest.get_modpath("i3") then + list_backgrounds = "style_type[box;colors=#666]" + for i=0, 2 do + for j=0, 2 do + list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 0.22+(j*1.25) ..";1,1;]" + end + end + for i=0, 3 do + for j=0, 2 do + list_backgrounds = list_backgrounds .. "box[".. 5.28+(i*1.25) ..",".. 0.22+(j*1.25) ..";1,1;]" + end + end + for i=0, 7 do + for j=0, 2 do + list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 4.5+(j*1.25) ..";1,1;]" + end + end + end + local size = "10.2,14" + local fs = + "formspec_version[2]".. + "size["..size.."]".. + pipeworks.fs_helpers.get_prepends(size).. + list_backgrounds.. + "list[context;recipe;0.22,0.22;3,3;]".. + "image[4,1.45;1,1;[combine:16x16^[noalpha^[colorize:#141318:255]".. + "list[context;output;4,1.45;1,1;]".. + "image_button[4,2.6;1,0.6;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" .. + "list[context;dst;5.28,0.22;4,3;]".. + "list[context;src;0.22,4.5;8,3;]".. + pipeworks.fs_helpers.get_inv(9).. + "listring[current_player;main]".. + "listring[context;src]" .. + "listring[current_player;main]".. + "listring[context;dst]" .. + "listring[current_player;main]" if minetest.get_modpath("digilines") then fs = fs.."field[0.3,3.5;4.5,1;channel;"..S("Channel")..";${channel}]".. "button[4.5,3.2;1.5,1;set_channel;"..S("Set").."]".. diff --git a/common.lua b/common.lua index 3d40491..4746906 100644 --- a/common.lua +++ b/common.lua @@ -143,6 +143,55 @@ function fs_helpers.cycling_button(meta, base, meta_name, values) return base..";"..(texture_name and texture_name..";" or "")..field..";"..minetest.formspec_escape(text)..(addopts and ";"..addopts or "").."]" end +function fs_helpers.get_inv(y) + local fs = {} + if minetest.get_modpath("i3") then + local inv_x = i3.settings.legacy_inventory and 0.75 or 0.22 + local inv_y = (y + 0.4) or 6.9 + local size, spacing = 1, 0.1 + local hotbar_len = i3.settings.hotbar_len + + table.insert(fs, "style_type[box;colors=#77777710,#77777710,#777,#777]") + + for i = 0, hotbar_len - 1 do + table.insert(fs, "box["..(i * size + inv_x + (i * spacing))..","..inv_y..";"..size..","..size..";]") + end + + table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") + table.insert(fs, "list[current_player;main;"..inv_x..","..inv_y..";"..hotbar_len..",1;]") + + table.insert(fs, "style_type[box;colors=#666]") + for i=0, 2 do + for j=0, (i3.settings.legacy_inventory and 7 or 8) do + table.insert(fs, "box["..0.2+(j*0.1)+(j*size)..","..(inv_y+size+spacing+0.05)+(i*0.1)+(i*size)..";"..size..","..size..";]") + end + end + + table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") + table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(i3.settings.inv_size / hotbar_len)..";"..hotbar_len.."]") + else + table.insert(fs, "list[current_player;main;0.22,"..y..";8,4;]") + end + + return table.concat(fs, "") +end + +function fs_helpers.get_prepends(size) + local prepend = {} + + if minetest.get_modpath("i3") then + prepend = { + "no_prepend[]", + "bgcolor[black;neither]", + "background9[0,0;"..size..";i3_bg_full.png;false;10]", + "style_type[button;border=false;bgimg=[combine:16x16^[noalpha^[colorize:#6b6b6b]", + "listcolors[#0000;#ffffff20]" + } + end + + return table.concat(prepend, "") +end + --------- -- Env -- --------- diff --git a/filter-injector.lua b/filter-injector.lua index a155307..6e25917 100644 --- a/filter-injector.lua +++ b/filter-injector.lua @@ -32,22 +32,35 @@ local function set_filter_formspec(data, meta) local exmatch_button = "" if data.stackwise then exmatch_button = - fs_helpers.cycling_button(meta, "button[4,3.5;4,1", "exmatch_mode", + fs_helpers.cycling_button(meta, "button["..(10.2-(0.22)-4)..",4.5;4,1", "exmatch_mode", {S("Exact match - off"), S("Exact match - on")}) end - - formspec = "size[8,8.5]".. - "item_image[0,0;1,1;pipeworks:"..data.name.."]".. - "label[1,0;"..minetest.formspec_escape(itemname).."]".. - "label[0,1;"..S("Prefer item types:").."]".. - "list[context;main;0,1.5;8,2;]".. - fs_helpers.cycling_button(meta, "button[0,3.5;4,1", "slotseq_mode", + local size = "10.2,11" + local list_backgrounds = "" + if minetest.get_modpath("i3") then + list_backgrounds = "style_type[box;colors=#666]" + for i=0, 7 do + for j=0, 1 do + list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 1.75+(j*1.25) ..";1,1;]" + end + end + end + formspec = + "formspec_version[2]".. + "size["..size.."]".. + pipeworks.fs_helpers.get_prepends(size).. + "item_image[0.22,0.22;1,1;pipeworks:"..data.name.."]".. + "label[1.22,0.72;"..minetest.formspec_escape(itemname).."]".. + "label[0.22,1.5;"..S("Prefer item types:").."]".. + list_backgrounds.. + "list[context;main;0.22,1.75;8,2;]".. + fs_helpers.cycling_button(meta, "button[0.22,4.5;4,1", "slotseq_mode", {S("Sequence slots by Priority"), S("Sequence slots Randomly"), S("Sequence slots by Rotation")}).. exmatch_button.. - "list[current_player;main;0,4.5;8,4;]" .. + pipeworks.fs_helpers.get_inv(6).. "listring[]" end meta:set_string("formspec", formspec) @@ -65,8 +78,8 @@ local function punch_filter(data, filtpos, filtnode, msg) local fromnode = minetest.get_node(frompos) if not fromnode then return end local fromdef = minetest.registered_nodes[fromnode.name] - if not fromdef then return end - local fromtube = fromdef.tube + if not fromdef or not fromdef.tube then return end + local fromtube = table.copy(fromdef.tube) local input_special_cases = { ["technic:mv_electric_furnace"] = "dst", ["technic:mv_electric_furnace_active"] = "dst", diff --git a/mod.conf b/mod.conf index c95a9c7..20b3214 100644 --- a/mod.conf +++ b/mod.conf @@ -1,5 +1,5 @@ name = pipeworks description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them. depends = basic_materials -optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api +optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3 min_minetest_version = 5.2.0 diff --git a/sorting_tubes.lua b/sorting_tubes.lua index 0168fad..d35308f 100644 --- a/sorting_tubes.lua +++ b/sorting_tubes.lua @@ -16,29 +16,43 @@ if pipeworks.enable_mese_tube then local buttons_formspec = "" for i = 0, 5 do buttons_formspec = buttons_formspec .. fs_helpers.cycling_button(meta, - "image_button[7,"..(i+0.2)..";1,0.6", "l"..(i+1).."s", + "image_button[9,"..(i+(i*0.25)+0.5)..";1,0.6", "l"..(i+1).."s", { pipeworks.button_off, pipeworks.button_on } ) end + local list_backgrounds = "" + if minetest.get_modpath("i3") then + list_backgrounds = "style_type[box;colors=#666]" + for i=0, 5 do + for j=0, 5 do + list_backgrounds = list_backgrounds .. "box[".. 1.5+(i*1.25) ..",".. 0.25+(j*1.25) ..";1,1;]" + end + end + end + local size = "10.2,13" meta:set_string("formspec", - "size[8,11]".. - "list[context;line1;1,0;6,1;]".. - "list[context;line2;1,1;6,1;]".. - "list[context;line3;1,2;6,1;]".. - "list[context;line4;1,3;6,1;]".. - "list[context;line5;1,4;6,1;]".. - "list[context;line6;1,5;6,1;]".. - "image[0,0;1,1;pipeworks_white.png]".. - "image[0,1;1,1;pipeworks_black.png]".. - "image[0,2;1,1;pipeworks_green.png]".. - "image[0,3;1,1;pipeworks_yellow.png]".. - "image[0,4;1,1;pipeworks_blue.png]".. - "image[0,5;1,1;pipeworks_red.png]".. + "formspec_version[2]".. + "size["..size.."]".. + pipeworks.fs_helpers.get_prepends(size).. + "list[context;line1;1.5,0.25;6,1;]".. + "list[context;line2;1.5,1.50;6,1;]".. + "list[context;line3;1.5,2.75;6,1;]".. + "list[context;line4;1.5,4.00;6,1;]".. + "list[context;line5;1.5,5.25;6,1;]".. + "list[context;line6;1.5,6.50;6,1;]".. + list_backgrounds.. + "image[0.22,0.25;1,1;pipeworks_white.png]".. + "image[0.22,1.50;1,1;pipeworks_black.png]".. + "image[0.22,2.75;1,1;pipeworks_green.png]".. + "image[0.22,4.00;1,1;pipeworks_yellow.png]".. + "image[0.22,5.25;1,1;pipeworks_blue.png]".. + "image[0.22,6.50;1,1;pipeworks_red.png]".. buttons_formspec.. - "list[current_player;main;0,7;8,4;]" .. + --"list[current_player;main;0,8;8,4;]" .. + pipeworks.fs_helpers.get_inv(8).. "listring[current_player;main]" .. "listring[current_player;main]" .. "listring[context;line1]" .. diff --git a/teleport_tube.lua b/teleport_tube.lua index b41d525..7250045 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -143,17 +143,19 @@ local function update_meta(meta, can_receive) local itext = S("Channels are public by default").."\n".. S("Use : for fully private channels").."\n".. S("Use \\; for private receivers") - + local size = "8.5,4" meta:set_string("formspec", - "size[8.5,3.5]".. - "image[0.2,o;1,1;pipeworks_teleport_tube_inv.png]".. - "label[1.2,0.2;"..S("Teleporting Tube").."]".. - "field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]".. - "button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]".. - "label[7.0,0;"..S("Receive").."]".. - "image_button[7.0,0.5;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]".. - "button_exit[6.3,1.3;2,1;close;"..S("Close").."]".. - "label[0.2,2.3;"..itext.."]") + "formspec_version[2]".. + "size["..size.."]".. + pipeworks.fs_helpers.get_prepends(size) .. + "image[0.5,o;1,1;pipeworks_teleport_tube_inv.png]".. + "label[1.5,0.5;"..S("Teleporting Tube").."]".. + "field[0.5,1.6;4.3,0.75;channel;"..S("Channel")..";${channel}]".. + "button[4.8,1.6;1.5,0.75;set_channel;"..S("Set").."]".. + "label[7.0,0.5;"..S("Receive").."]".. + "image_button[7.0,0.75;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]".. + "button_exit[6.3,1.6;2,0.75;close;"..S("Close").."]".. + "label[0.5,2.7;"..itext.."]") end pipeworks.register_tube("pipeworks:teleport_tube", { diff --git a/trashcan.lua b/trashcan.lua index e106761..3643828 100644 --- a/trashcan.lua +++ b/trashcan.lua @@ -20,13 +20,24 @@ minetest.register_node("pipeworks:trashcan", { }, on_construct = function(pos) local meta = minetest.get_meta(pos) + local size = "10.2,9" + local list_background = "" + if minetest.get_modpath("i3") then + list_background = "style_type[box;colors=#666]box[4.5,2;1,1;]" + end meta:set_string("formspec", - "size[8,7]".. - "item_image[0,0;1,1;pipeworks:trashcan]".. - "label[1,0;"..S("Trash Can").."]".. - "list[context;trash;3.5,1;1,1;]".. - "list[current_player;main;0,3;8,4;]" .. - "listring[]") + "formspec_version[2]" .. + "size["..size.."]".. + pipeworks.fs_helpers.get_prepends(size) .. + "item_image[0.5,0.5;1,1;pipeworks:trashcan]".. + "label[1.5,1;"..S("Trash Can").."]".. + list_background.. + "list[context;trash;4.5,2;1,1;]".. + --"list[current_player;main;0,3;8,4;]" .. + pipeworks.fs_helpers.get_inv(4).. + "listring[context;trash]".. + "listring[current_player;main]" + ) meta:set_string("infotext", S("Trash Can")) meta:get_inventory():set_size("trash", 1) end, diff --git a/vacuum_tubes.lua b/vacuum_tubes.lua index f6a3546..684e6cf 100644 --- a/vacuum_tubes.lua +++ b/vacuum_tubes.lua @@ -39,9 +39,11 @@ if pipeworks.enable_mese_sand_tube then groups = {vacuum_tube = 1}, on_construct = function(pos) local meta = minetest.get_meta(pos) + local size = "6.0,2.4" meta:set_int("dist", 0) meta:set_string("formspec", - "size[6.0,2.2]".. + "size["..size.."]".. + pipeworks.fs_helpers.get_prepends(size) .. "image[0.2,0;1,1;pipeworks_mese_sand_tube_inv.png]".. "label[1.2,0.2;"..S("Adjustable Vacuuming Tube").."]".. "field[0.5,1.6;2.1,1;dist;"..S("Radius")..";${dist}]".. diff --git a/wielder.lua b/wielder.lua index 92d121a..21a6126 100644 --- a/wielder.lua +++ b/wielder.lua @@ -6,13 +6,28 @@ local function delay(x) end local function set_wielder_formspec(data, meta) + local size = "10.2,"..(7+data.wield_inv_height) + local list_background = "" + if minetest.get_modpath("i3") then + list_background = "style_type[box;colors=#666]" + for i=0, data.wield_inv_height-1 do + for j=0, data.wield_inv_width-1 do + list_background = list_background .. "box[".. ((10-data.wield_inv_width)*0.5)+(i*1.25) ..",".. 1+(j*1.25) ..";1,1;]" + end + end + end meta:set_string("formspec", - "size[8,"..(6+data.wield_inv_height)..";]".. - "item_image[0,0;1,1;"..data.name_base.."_off]".. - "label[1,0;"..minetest.formspec_escape(data.description).."]".. - "list[current_name;"..minetest.formspec_escape(data.wield_inv_name)..";"..((8-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]".. - "list[current_player;main;0,"..(2+data.wield_inv_height)..";8,4;]" .. - "listring[]") + "formspec_version[2]" .. + "size["..size.."]".. + pipeworks.fs_helpers.get_prepends(size).. + "item_image[0.5,0.5;1,1;"..data.name_base.."_off]".. + "label[1.5,1;"..minetest.formspec_escape(data.description).."]".. + list_background .. + "list[current_name;"..minetest.formspec_escape(data.wield_inv_name)..";"..((10-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]".. + pipeworks.fs_helpers.get_inv((2+data.wield_inv_height)) + --"list[current_player;main;0,"..(2+data.wield_inv_height)..";8,4;]" .. + --"listring[]" + ) meta:set_string("infotext", data.description) end From 97903327a55c975492d33961b6f7b829dff06a8d Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Fri, 6 May 2022 11:25:02 -0400 Subject: [PATCH 14/40] Add option to forego real entities (#26) --- default_settings.lua | 1 + luaentity.lua | 52 +++++++++++++++++++++++++++----------------- settingtypes.txt | 3 +++ 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/default_settings.lua b/default_settings.lua index 9f21778..975b1d6 100644 --- a/default_settings.lua +++ b/default_settings.lua @@ -27,6 +27,7 @@ local settings = { enable_cyclic_mode = true, drop_on_routing_fail = false, delete_item_on_clearobject = true, + use_real_entities = true, } pipeworks.toggles = {} diff --git a/luaentity.lua b/luaentity.lua index 83fb4d9..27799dd 100644 --- a/luaentity.lua +++ b/luaentity.lua @@ -73,31 +73,43 @@ local function get_blockpos(pos) z = math.floor(pos.z / 16)} end -local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones) +local move_entities_globalstep_part1 +local is_active -local move_entities_globalstep_part1 = function(dtime) - local active_block_range = tonumber(minetest.settings:get("active_block_range")) or 2 - local new_active_blocks = {} - for _, player in ipairs(minetest.get_connected_players()) do - local blockpos = get_blockpos(player:get_pos()) - local minp = vector.subtract(blockpos, active_block_range) - local maxp = vector.add(blockpos, active_block_range) +if pipeworks.use_real_entities then + local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones) - for x = minp.x, maxp.x do - for y = minp.y, maxp.y do - for z = minp.z, maxp.z do - local pos = {x = x, y = y, z = z} - new_active_blocks[minetest.hash_node_position(pos)] = pos - end - end + move_entities_globalstep_part1 = function(dtime) + local active_block_range = tonumber(minetest.settings:get("active_block_range")) or 2 + local new_active_blocks = {} + for _, player in ipairs(minetest.get_connected_players()) do + local blockpos = get_blockpos(player:get_pos()) + local minp = vector.subtract(blockpos, active_block_range) + local maxp = vector.add(blockpos, active_block_range) + + for x = minp.x, maxp.x do + for y = minp.y, maxp.y do + for z = minp.z, maxp.z do + local pos = {x = x, y = y, z = z} + new_active_blocks[minetest.hash_node_position(pos)] = pos + end + end + end end + active_blocks = new_active_blocks + -- todo: callbacks on block load/unload end - active_blocks = new_active_blocks - -- todo: callbacks on block load/unload -end -local function is_active(pos) - return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil + is_active = function(pos) + return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil + end +else + move_entities_globalstep_part1 = function() + end + + is_active = function() + return false + end end local entitydef_default = { diff --git a/settingtypes.txt b/settingtypes.txt index cd6efbc..bfe7735 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -75,3 +75,6 @@ pipeworks_drop_on_routing_fail (Drop On Routing Fail) bool false #Delete item on clearobject. pipeworks_delete_item_on_clearobject (Delete Item On Clearobject) bool true + +#Use real visible entities in tubes within active areas. +pipeworks_use_real_entities (Use real entities) bool true From e3d94cb3a88c017f7d5c04dcb2e7b390d8707661 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Sat, 7 May 2022 17:04:06 -0400 Subject: [PATCH 15/40] fix digiline formspec spacing (#27) --- autocrafter.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 60cfc2b..ca578e9 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -187,7 +187,7 @@ local function update_meta(meta, enabled) end for i=0, 7 do for j=0, 2 do - list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 4.5+(j*1.25) ..";1,1;]" + list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 5+(j*1.25) ..";1,1;]" end end end @@ -202,7 +202,7 @@ local function update_meta(meta, enabled) "list[context;output;4,1.45;1,1;]".. "image_button[4,2.6;1,0.6;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" .. "list[context;dst;5.28,0.22;4,3;]".. - "list[context;src;0.22,4.5;8,3;]".. + "list[context;src;0.22,5;8,3;]".. pipeworks.fs_helpers.get_inv(9).. "listring[current_player;main]".. "listring[context;src]" .. @@ -210,9 +210,9 @@ local function update_meta(meta, enabled) "listring[context;dst]" .. "listring[current_player;main]" if minetest.get_modpath("digilines") then - fs = fs.."field[0.3,3.5;4.5,1;channel;"..S("Channel")..";${channel}]".. - "button[4.5,3.2;1.5,1;set_channel;"..S("Set").."]".. - "button_exit[6,3.2;2,1;close;"..S("Close").."]" + fs = fs.."field[0.22,4.1;4.5,0.75;channel;"..S("Channel")..";${channel}]".. + "button[5,4.1;1.5,0.75;set_channel;"..S("Set").."]".. + "button_exit[6.8,4.1;2,0.75;close;"..S("Close").."]" end meta:set_string("formspec",fs) From 55ded7e5698589ef4bc8d9f7080b5833106c3911 Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Wed, 11 May 2022 18:41:28 -0400 Subject: [PATCH 16/40] Make tubes opaque when entities are not used (#29) * Make tubes opaque when entities are not used --- decorative_tubes.lua | 13 +++++++------ init.lua | 23 +++++++++++++++++++++++ routing_tubes.lua | 8 ++++++-- settingtypes.txt | 1 + tube_registration.lua | 4 ++++ 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/decorative_tubes.lua b/decorative_tubes.lua index d79f8af..910ea91 100644 --- a/decorative_tubes.lua +++ b/decorative_tubes.lua @@ -49,12 +49,13 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", { drawtype = "nodebox", description = S("Airtight panel embedded tube"), tiles = { - "pipeworks_pane_embedded_tube_sides.png^[transformR90", - "pipeworks_pane_embedded_tube_sides.png^[transformR90", - "pipeworks_pane_embedded_tube_sides.png", - "pipeworks_pane_embedded_tube_sides.png", - "pipeworks_pane_embedded_tube_ends.png", "pipeworks_pane_embedded_tube_ends.png", - }, + pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png^[transformR90"), + 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"), + }, use_texture_alpha = texture_alpha_mode, node_box = pane_box, selection_box = pane_box, diff --git a/init.lua b/init.lua index 8fb0b31..65de26a 100644 --- a/init.lua +++ b/init.lua @@ -69,6 +69,29 @@ function pipeworks.fix_image_names(table, replacement) return outtable end +local function overlay_tube_texture(texture) + -- The texture appears the first time to be colorized as the opaque background. + return ("(%s)^[noalpha^[colorize:#dadada^(%s)"):format(texture, texture) +end + +function pipeworks.make_tube_tile(tile) + if pipeworks.use_real_entities then + return tile + elseif type(tile) == "string" then + return overlay_tube_texture(tile) + else + tile = table.copy(tile) + if tile.color then + -- Won't work 100% of the time, but good enough. + tile.name = tile.name .. "^[multiply:" .. minetest.colorspec_to_colorstring(tile.color) + tile.color = nil + end + tile.name = overlay_tube_texture(tile.name) + tile.backface_culling = nil -- The texture is opaque + return tile + end +end + function pipeworks.add_node_box(t, b) if not t or not b then return end for i in ipairs(b) diff --git a/routing_tubes.lua b/routing_tubes.lua index 5e5fe0a..5fc1d82 100644 --- a/routing_tubes.lua +++ b/routing_tubes.lua @@ -143,10 +143,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"} + for i, tile in ipairs(tiles) do + tiles[i] = pipeworks.make_tube_tile(tile) + end minetest.register_node("pipeworks:one_way_tube", { description = S("One way tube"), - 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"}, + tiles = tiles, use_texture_alpha = texture_alpha_mode, paramtype2 = "facedir", drawtype = "nodebox", diff --git a/settingtypes.txt b/settingtypes.txt index bfe7735..3a6cbf4 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -77,4 +77,5 @@ pipeworks_drop_on_routing_fail (Drop On Routing Fail) bool false pipeworks_delete_item_on_clearobject (Delete Item On Clearobject) bool true #Use real visible entities in tubes within active areas. +#When disabled, tubes are made opaque. pipeworks_use_real_entities (Use real entities) bool true diff --git a/tube_registration.lua b/tube_registration.lua index c621cd8..edb9f5e 100644 --- a/tube_registration.lua +++ b/tube_registration.lua @@ -80,6 +80,10 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e 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) From 4fce320d9c84b35d221ca9d9ea8a6b4bc4ffb64e Mon Sep 17 00:00:00 2001 From: sfence Date: Fri, 13 May 2022 04:52:17 +0200 Subject: [PATCH 17/40] Better Hades Revisited support (#30) * Fix spaces vs tabs in crafts.lua * Fix recipes, add telepoter device for teleporter tube recipe. * Override chests and furnaces in Hades as well. --- compat-chests.lua | 140 ++++++++++++++++++++++++---------- compat-furnaces.lua | 26 +++++-- crafts.lua | 179 +++++++++++++++++++++++--------------------- init.lua | 2 +- mod.conf | 2 +- 5 files changed, 215 insertions(+), 134 deletions(-) diff --git a/compat-chests.lua b/compat-chests.lua index 2da00ea..0448660 100644 --- a/compat-chests.lua +++ b/compat-chests.lua @@ -11,33 +11,72 @@ local tube_entry = "^pipeworks_tube_connection_wooden.png" -- Chest Locals local open_chests = {} -local function get_chest_formspec(pos) - local spos = pos.x .. "," .. pos.y .. "," .. pos.z - local formspec = - "size[8,9]" .. - default.gui_bg .. - default.gui_bg_img .. - default.gui_slots .. - "list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" .. - "list[current_player;main;0,4.85;8,1;]" .. - "list[current_player;main;0,6.08;8,3;8]" .. - "listring[nodemeta:" .. spos .. ";main]" .. - "listring[current_player;main]" .. - default.get_hotbar_bg(0,4.85) +local get_chest_formspec - -- Pipeworks Switch - formspec = formspec .. - fs_helpers.cycling_button( - minetest.get_meta(pos), - pipeworks.button_base, - "splitstacks", - { - pipeworks.button_off, - pipeworks.button_on - } - )..pipeworks.button_label +if minetest.get_modpath("default") then + function get_chest_formspec(pos) + local spos = pos.x .. "," .. pos.y .. "," .. pos.z + local formspec = + "size[8,9]" .. + default.gui_bg .. + default.gui_bg_img .. + default.gui_slots .. + "list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" .. + "list[current_player;main;0,4.85;8,1;]" .. + "list[current_player;main;0,6.08;8,3;8]" .. + "listring[nodemeta:" .. spos .. ";main]" .. + "listring[current_player;main]" .. + default.get_hotbar_bg(0,4.85) - return formspec + -- Pipeworks Switch + formspec = formspec .. + fs_helpers.cycling_button( + minetest.get_meta(pos), + pipeworks.button_base, + "splitstacks", + { + pipeworks.button_off, + pipeworks.button_on + } + )..pipeworks.button_label + + return formspec + end +else + local function get_hotbar_bg(x,y) + local out = "" + for i=0,7,1 do + out = out .."image["..x+i..","..y..";1,1;gui_hb_bg.png]" + end + return out + end + + function get_chest_formspec(pos) + local spos = pos.x .. "," .. pos.y .. "," .. pos.z + local formspec = + "size[10,9]" .. + "background9[8,8;8,9;hades_chests_chestui.png;true;8]".. + "list[nodemeta:" .. spos .. ";main;0,0.3;10,4;]" .. + "list[current_player;main;0,4.85;10,1;]" .. + "list[current_player;main;0,6.08;10,3;10]" .. + "listring[nodemeta:" .. spos .. ";main]" .. + "listring[current_player;main]" .. + get_hotbar_bg(0,4.85) + + -- Pipeworks Switch + formspec = formspec .. + fs_helpers.cycling_button( + minetest.get_meta(pos), + pipeworks.button_base, + "splitstacks", + { + pipeworks.button_off, + pipeworks.button_on + } + )..pipeworks.button_label + + return formspec + end end local function chest_lid_obstructed(pos) @@ -71,7 +110,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end minetest.after(0.2, function() - minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 }) + if minetest.get_modpath("default") then + minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 }) + end -- Pipeworks notification pipeworks.after_place(pos) @@ -88,10 +129,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end) -- Original Definitions -local old_chest_def = table.copy(minetest.registered_items["default:chest"]) -local old_chest_open_def = table.copy(minetest.registered_items["default:chest_open"]) -local old_chest_locked_def = table.copy(minetest.registered_items["default:chest_locked"]) -local old_chest_locked_open_def = table.copy(minetest.registered_items["default:chest_locked_open"]) +local old_chest_def, old_chest_open_def, old_chest_locked_def, old_chest_locked_open_def +if minetest.get_modpath("default") then + old_chest_def = table.copy(minetest.registered_items["default:chest"]) + old_chest_open_def = table.copy(minetest.registered_items["default:chest_open"]) + old_chest_locked_def = table.copy(minetest.registered_items["default:chest_locked"]) + old_chest_locked_open_def = table.copy(minetest.registered_items["default:chest_locked_open"]) +elseif minetest.get_modpath("hades_chests") then + old_chest_def = table.copy(minetest.registered_items["hades_chests:chest"]) + old_chest_open_def = table.copy(minetest.registered_items["hades_chests:chest"]) + old_chest_locked_def = table.copy(minetest.registered_items["hades_chests:chest_locked"]) + old_chest_locked_open_def = table.copy(minetest.registered_items["hades_chests:chest_locked"]) +end -- Override Construction local override_protected, override, override_open, override_protected_open @@ -116,9 +165,11 @@ override_protected = { minetest.sound_play(old_chest_locked_def.sound_open, {gain = 0.3, pos = pos, max_hear_distance = 10}) if not chest_lid_obstructed(pos) then - minetest.swap_node(pos, - { name = "default:" .. "chest_locked" .. "_open", - param2 = node.param2 }) + if minetest.get_modpath("default") then + minetest.swap_node(pos, + { name = "default:" .. "chest_locked" .. "_open", + param2 = node.param2 }) + end end minetest.after(0.2, minetest.show_formspec, clicker:get_player_name(), @@ -160,9 +211,11 @@ override = { minetest.sound_play(old_chest_def.sound_open, {gain = 0.3, pos = pos, max_hear_distance = 10}) if not chest_lid_obstructed(pos) then - minetest.swap_node(pos, { - name = "default:" .. "chest" .. "_open", - param2 = node.param2 }) + if minetest.get_modpath("default") then + minetest.swap_node(pos, { + name = "default:" .. "chest" .. "_open", + param2 = node.param2 }) + end end minetest.after(0.2, minetest.show_formspec, clicker:get_player_name(), @@ -236,8 +289,15 @@ for _,v in ipairs({override_protected, override, override_open, override_protect end -- Override with the new modifications. -minetest.override_item("default:chest", override) -minetest.override_item("default:chest_open", override_open) -minetest.override_item("default:chest_locked", override_protected) -minetest.override_item("default:chest_locked_open", override_protected_open) +if minetest.get_modpath("default") then + minetest.override_item("default:chest", override) + minetest.override_item("default:chest_open", override_open) + minetest.override_item("default:chest_locked", override_protected) + minetest.override_item("default:chest_locked_open", override_protected_open) +elseif minetest.get_modpath("hades_chests") then + minetest.override_item("hades_chests:chest", override) + --minetest.override_item("hades_chests:chest_open", override_open) + minetest.override_item("hades_chests:chest_locked", override_protected) + --minetest.override_item("hades_chests:chest_locked_open", override_protected_open) +end diff --git a/compat-furnaces.lua b/compat-furnaces.lua index 776a526..432aff1 100644 --- a/compat-furnaces.lua +++ b/compat-furnaces.lua @@ -1,8 +1,14 @@ -- this file is basically a modified copy of -- minetest_game/mods/default/furnaces.lua -local def = table.copy(minetest.registered_nodes["default:furnace"]) ---local def_active = table.copy(minetest.registered_nodes["default:furnace_active"]) +local def--, def_active +if minetest.get_modpath("default") then + def = table.copy(minetest.registered_nodes["default:furnace"]) + --def_active = table.copy(minetest.registered_nodes["default:furnace_active"]) +elseif minetest.get_modpath("hades_furnaces") then + def = table.copy(minetest.registered_nodes["hades_furnaces:furnace"]) + --def_active = table.copy(minetest.registered_nodes["hades_furnaces:furnace_active"]) +end local tube_entry = "^pipeworks_tube_connection_stony.png" @@ -16,7 +22,7 @@ groups_active["not_in_creative_inventory"] = 1 -- Node definitions -- -minetest.override_item("default:furnace", { +local override = { tiles = { "default_furnace_top.png"..tube_entry, "default_furnace_bottom.png"..tube_entry, @@ -59,9 +65,9 @@ minetest.override_item("default:furnace", { after_place_node = pipeworks.after_place, after_dig_node = pipeworks.after_dig, on_rotate = pipeworks.on_rotate -}) +} -minetest.override_item("default:furnace_active", { +local override_active = { tiles = { "default_furnace_top.png"..tube_entry, "default_furnace_bottom.png"..tube_entry, @@ -110,5 +116,13 @@ minetest.override_item("default:furnace_active", { after_place_node = pipeworks.after_place, after_dig_node = pipeworks.after_dig, on_rotate = pipeworks.on_rotate -}) +} + +if minetest.get_modpath("default") then + minetest.override_item("default:furnace", override) + minetest.override_item("default:furnace_active", override_active) +elseif minetest.get_modpath("hades_furnaces") then + minetest.override_item("hades_furnaces:furnace", override) + minetest.override_item("hades_furnaces:furnace_active", override_active) +end diff --git a/crafts.lua b/crafts.lua index ea44660..6d261a0 100644 --- a/crafts.lua +++ b/crafts.lua @@ -6,10 +6,11 @@ local materials = { copper_ingot = "default:copper_ingot", steel_ingot = "default:steel_ingot", gold_ingot = "default:gold_ingot", - mese = "default:mese", - mese_crystal = "default:mese_crystal", + mese = "default:mese", + mese_crystal = "default:mese_crystal", mese_crystal_fragment = "default:mese_crystal_fragment", - glass = "default:glass", + teleporter = "default:mese", + glass = "default:glass", } if minetest.get_modpath("mcl_core") then @@ -20,12 +21,13 @@ if minetest.get_modpath("mcl_core") then chest = "mcl_chests:chest_small", steel_ingot = "mcl_core:iron_ingot", gold_ingot = "mcl_core:gold_ingot", - mese = "default:mese", - mese_crystal = "default:mese_crystal", + mese = "default:mese", + mese_crystal = "default:mese_crystal", mese_crystal_fragment = "mesecons:redstone", + teleporter = "default:mese", -- Use iron where no equivalent copper_ingot = "mcl_core:iron_ingot", - glass = "default:glass", + glass = "default:glass", } elseif minetest.get_modpath("fl_ores") and minetest.get_modpath("fl_stone") then materials = { @@ -35,115 +37,120 @@ elseif minetest.get_modpath("fl_ores") and minetest.get_modpath("fl_stone") then chest = "fl_storage:wood_chest", steel_ingot = "fl_ores:iron_ingot", gold_ingot = "fl_ores:gold_ingot", - mese = "fl_ores:iron_ingot", - mese_crystal = "fl_ores:iron_ingot", + mese = "fl_ores:iron_ingot", + mese_crystal = "fl_ores:iron_ingot", mese_crystal_fragment = "fl_ores:iron_ingot", + teleporter = "fl_ores:iron_ingot", copper_ingot = "fl_ores:copper_ingot", - glass = "fl_glass:framed_glass", + glass = "fl_glass:framed_glass", } elseif minetest.get_modpath("hades_core") then materials = { stone = "hades_core:stone", - desert_stone = "hades_core:desert_stone", - desert_sand = "hades_core:desert_sand", - chest = "hades_core:chest"; + desert_stone = "hades_core:stone_baked", + desert_sand = "hades_core:volcanic_sand", + chest = "hades_chests:chest"; steel_ingot = "hades_core:steel_ingot", gold_ingot = "hades_core:gold_ingot", - mese = "hades_core:mese", - mese_crystal = "hades_core:mese_crystal", + mese = "hades_core:mese", + mese_crystal = "hades_core:mese_crystal", mese_crystal_fragment = "hades_core:mese_crystal_fragment", + teleporter = "hades_materials:teleporter_device", copper_ingot = "hades_core:copper_ingot", tin_ingot = "hades_core:tin_ingot", - glass = "default:glass", + glass = "hades_core:glass", } + if minetest.get_modpath("hades_default") then + materials.desert_sand = "hades_default:desert_sand" + end end -- Crafting recipes for pipes minetest.register_craft( { - output = "pipeworks:pipe_1_empty 12", - recipe = { - { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }, - { "", "", "" }, - { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot } - }, + output = "pipeworks:pipe_1_empty 12", + recipe = { + { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }, + { "", "", "" }, + { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot } + }, }) minetest.register_craft( { - output = "pipeworks:straight_pipe_empty 3", - recipe = { - { "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty" }, - }, + output = "pipeworks:straight_pipe_empty 3", + recipe = { + { "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty" }, + }, }) minetest.register_craft( { - output = "pipeworks:spigot 3", - recipe = { - { "pipeworks:pipe_1_empty", "" }, - { "", "pipeworks:pipe_1_empty" }, - }, + output = "pipeworks:spigot 3", + recipe = { + { "pipeworks:pipe_1_empty", "" }, + { "", "pipeworks:pipe_1_empty" }, + }, }) minetest.register_craft( { output = "pipeworks:entry_panel_empty 2", recipe = { - { "", materials.steel_ingot, "" }, - { "", "pipeworks:pipe_1_empty", "" }, - { "", materials.steel_ingot, "" }, + { "", materials.steel_ingot, "" }, + { "", "pipeworks:pipe_1_empty", "" }, + { "", materials.steel_ingot, "" }, }, }) -- Various ancillary pipe devices minetest.register_craft( { - output = "pipeworks:pump_off 2", - recipe = { - { materials.stone, materials.steel_ingot, materials.stone }, - { materials.copper_ingot, materials.mese_crystal_fragment, materials.copper_ingot }, - { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot } - }, + output = "pipeworks:pump_off 2", + recipe = { + { materials.stone, materials.steel_ingot, materials.stone }, + { materials.copper_ingot, materials.mese_crystal_fragment, materials.copper_ingot }, + { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot } + }, }) minetest.register_craft( { - output = "pipeworks:valve_off_empty 2", - recipe = { - { "", "group:stick", "" }, - { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }, - { "", materials.steel_ingot, "" } - }, + output = "pipeworks:valve_off_empty 2", + recipe = { + { "", "group:stick", "" }, + { materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }, + { "", materials.steel_ingot, "" } + }, }) minetest.register_craft( { - output = "pipeworks:storage_tank_0 2", - recipe = { - { "", materials.steel_ingot, materials.steel_ingot }, - { materials.steel_ingot, materials.glass, materials.steel_ingot }, - { materials.steel_ingot, materials.steel_ingot, "" } - }, + output = "pipeworks:storage_tank_0 2", + recipe = { + { "", materials.steel_ingot, materials.steel_ingot }, + { materials.steel_ingot, materials.glass, materials.steel_ingot }, + { materials.steel_ingot, materials.steel_ingot, "" } + }, }) minetest.register_craft( { - output = "pipeworks:grating 2", - recipe = { - { materials.steel_ingot, "", materials.steel_ingot }, - { "", "pipeworks:pipe_1_empty", "" }, - { materials.steel_ingot, "", materials.steel_ingot } - }, + output = "pipeworks:grating 2", + recipe = { + { materials.steel_ingot, "", materials.steel_ingot }, + { "", "pipeworks:pipe_1_empty", "" }, + { materials.steel_ingot, "", materials.steel_ingot } + }, }) minetest.register_craft( { - output = "pipeworks:flow_sensor_empty 2", - recipe = { - { "pipeworks:pipe_1_empty", "mesecons:mesecon", "pipeworks:pipe_1_empty" }, - }, + output = "pipeworks:flow_sensor_empty 2", + recipe = { + { "pipeworks:pipe_1_empty", "mesecons:mesecon", "pipeworks:pipe_1_empty" }, + }, }) minetest.register_craft( { - output = "pipeworks:fountainhead 2", - recipe = { - { "pipeworks:pipe_1_empty" }, - { "pipeworks:pipe_1_empty" } - }, + output = "pipeworks:fountainhead 2", + recipe = { + { "pipeworks:pipe_1_empty" }, + { "pipeworks:pipe_1_empty" } + }, }) -- injectors @@ -151,18 +158,18 @@ minetest.register_craft( { minetest.register_craft( { output = "pipeworks:filter 2", recipe = { - { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }, - { "group:stick", materials.mese_crystal, "basic_materials:plastic_sheet" }, - { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" } + { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }, + { "group:stick", materials.mese_crystal, "basic_materials:plastic_sheet" }, + { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" } }, }) minetest.register_craft( { output = "pipeworks:mese_filter 2", recipe = { - { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }, - { "group:stick", materials.mese, "basic_materials:plastic_sheet" }, - { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" } + { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }, + { "group:stick", materials.mese, "basic_materials:plastic_sheet" }, + { materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" } }, }) @@ -182,9 +189,9 @@ end minetest.register_craft( { output = "pipeworks:autocrafter 2", recipe = { - { materials.steel_ingot, materials.mese_crystal, materials.steel_ingot }, - { "basic_materials:plastic_sheet", materials.steel_ingot, "basic_materials:plastic_sheet" }, - { materials.steel_ingot, materials.mese_crystal, materials.steel_ingot } + { materials.steel_ingot, materials.mese_crystal, materials.steel_ingot }, + { "basic_materials:plastic_sheet", materials.steel_ingot, "basic_materials:plastic_sheet" }, + { materials.steel_ingot, materials.mese_crystal, materials.steel_ingot } }, }) @@ -218,9 +225,9 @@ minetest.register_craft({ minetest.register_craft( { output = "pipeworks:teleport_tube_1 2", recipe = { - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, - { materials.desert_stone, materials.mese, materials.desert_stone }, - { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, + { materials.desert_stone, materials.teleporter, materials.desert_stone }, + { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } }, }) @@ -296,7 +303,7 @@ if pipeworks.enable_mese_sand_tube then output = "pipeworks:mese_sand_tube_1 2", recipe = { {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }, - {"group:sand", materials.mese_crystal, "group:sand" }, + {"group:sand", materials.mese_crystal, "group:sand" }, {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" } }, }) @@ -318,7 +325,7 @@ if pipeworks.enable_deployer then minetest.register_craft({ output = "pipeworks:deployer_off", recipe = { - { "group:wood", "default:chest", "group:wood" }, + { "group:wood", materials.chest, "group:wood" }, { materials.stone, "mesecons:piston", materials.stone }, { materials.stone, "mesecons:mesecon", materials.stone }, } @@ -329,9 +336,9 @@ if pipeworks.enable_dispenser then minetest.register_craft({ output = "pipeworks:dispenser_off", recipe = { - { materials.desert_sand, materials.chest, materials.desert_sand }, - { materials.stone, "mesecons:piston", materials.stone }, - { materials.stone, "mesecons:mesecon", materials.stone }, + { materials.desert_sand, materials.chest, materials.desert_sand }, + { materials.stone, "mesecons:piston", materials.stone }, + { materials.stone, "mesecons:mesecon", materials.stone }, } }) end @@ -340,9 +347,9 @@ if pipeworks.enable_node_breaker then minetest.register_craft({ output = "pipeworks:nodebreaker_off", recipe = { - { "basic_materials:gear_steel", "basic_materials:gear_steel", "basic_materials:gear_steel" }, + { "basic_materials:gear_steel", "basic_materials:gear_steel", "basic_materials:gear_steel" }, { materials.stone, "mesecons:piston", materials.stone }, - { "group:wood", "mesecons:mesecon", "group:wood" }, + { "group:wood", "mesecons:mesecon", "group:wood" }, } }) -end \ No newline at end of file +end diff --git a/init.lua b/init.lua index 65de26a..b9d95b0 100644 --- a/init.lua +++ b/init.lua @@ -170,7 +170,7 @@ dofile(pipeworks.modpath..logicdir.."flowable_node_registry_install.lua") if pipeworks.enable_pipes then dofile(pipeworks.modpath.."/pipes.lua") end if pipeworks.enable_teleport_tube then dofile(pipeworks.modpath.."/teleport_tube.lua") end if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end -if pipeworks.enable_redefines and minetest.get_modpath("default") then +if pipeworks.enable_redefines and (minetest.get_modpath("default") or minetest.get_modpath("hades_core")) then dofile(pipeworks.modpath.."/compat-chests.lua") dofile(pipeworks.modpath.."/compat-furnaces.lua") end diff --git a/mod.conf b/mod.conf index 20b3214..2b390b6 100644 --- a/mod.conf +++ b/mod.conf @@ -1,5 +1,5 @@ name = pipeworks description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them. depends = basic_materials -optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3 +optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests min_minetest_version = 5.2.0 From 3b31b6f9c04e9e1b4927a602161122b9060fdfe8 Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Fri, 13 May 2022 22:10:40 -0400 Subject: [PATCH 18/40] fix https://github.com/mt-mods/pipeworks/issues/31 --- wielder.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wielder.lua b/wielder.lua index 21a6126..8b66df5 100644 --- a/wielder.lua +++ b/wielder.lua @@ -24,9 +24,9 @@ local function set_wielder_formspec(data, meta) "label[1.5,1;"..minetest.formspec_escape(data.description).."]".. list_background .. "list[current_name;"..minetest.formspec_escape(data.wield_inv_name)..";"..((10-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]".. - pipeworks.fs_helpers.get_inv((2+data.wield_inv_height)) - --"list[current_player;main;0,"..(2+data.wield_inv_height)..";8,4;]" .. - --"listring[]" + pipeworks.fs_helpers.get_inv((2+data.wield_inv_height)) .. + "listring[context;main]" .. + "listring[current_player;main]" ) meta:set_string("infotext", data.description) end From 1349ff8dd8dc55ed55b108148593743d4b3d34f0 Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Sun, 15 May 2022 10:58:35 -0400 Subject: [PATCH 19/40] Return early from on_step (#33) --- item_transport.lua | 78 ++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/item_transport.lua b/item_transport.lua index 76fe538..7e83d95 100644 --- a/item_transport.lua +++ b/item_transport.lua @@ -311,8 +311,6 @@ luaentity.register_entity("pipeworks:tubed_item", { self:set_pos(pos) end - local stack = ItemStack(self.itemstring) - local velocity = self:get_velocity() local moved = false @@ -329,9 +327,15 @@ luaentity.register_entity("pipeworks:tubed_item", { moved = true end + if not moved then + return + end + + local stack = ItemStack(self.itemstring) + pipeworks.load_position(self.start_pos) local node = minetest.get_node(self.start_pos) - if moved and minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then + if minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then local leftover if minetest.registered_nodes[node.name].tube and minetest.registered_nodes[node.name].tube.insert_object then leftover = minetest.registered_nodes[node.name].tube.insert_object(self.start_pos, node, stack, vel, self.owner) @@ -349,45 +353,43 @@ luaentity.register_entity("pipeworks:tubed_item", { return end - if moved then - local found_next, new_velocity, multimode = go_next(self.start_pos, velocity, stack, self.owner) -- todo: color - local rev_vel = vector.multiply(velocity, -1) - local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel)) - local rev_node = minetest.get_node(vector.round(vector.add(self.start_pos,rev_dir))) - local tube_present = minetest.get_item_group(rev_node.name,"tubedevice") == 1 - if not found_next then - if pipeworks.drop_on_routing_fail or not tube_present or - minetest.get_item_group(rev_node.name,"tube") ~= 1 then - -- Using add_item instead of item_drop since this makes pipeworks backward - -- compatible with Minetest 0.4.13. - -- Using item_drop here makes Minetest 0.4.13 crash. - local dropped_item = minetest.add_item(self.start_pos, stack) - if dropped_item then - dropped_item:set_velocity(vector.multiply(velocity, 5)) - self:remove() - end - return - else - velocity = vector.multiply(velocity, -1) - self:set_pos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1))) - self:set_velocity(velocity) + local found_next, new_velocity, multimode = go_next(self.start_pos, velocity, stack, self.owner) -- todo: color + local rev_vel = vector.multiply(velocity, -1) + local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel)) + local rev_node = minetest.get_node(vector.round(vector.add(self.start_pos,rev_dir))) + local tube_present = minetest.get_item_group(rev_node.name,"tubedevice") == 1 + if not found_next then + if pipeworks.drop_on_routing_fail or not tube_present or + minetest.get_item_group(rev_node.name,"tube") ~= 1 then + -- Using add_item instead of item_drop since this makes pipeworks backward + -- compatible with Minetest 0.4.13. + -- Using item_drop here makes Minetest 0.4.13 crash. + local dropped_item = minetest.add_item(self.start_pos, stack) + if dropped_item then + dropped_item:set_velocity(vector.multiply(velocity, 5)) + self:remove() end - elseif is_multimode(multimode) then - -- create new stacks according to returned data. - local s = self.start_pos - for _, split in ipairs(multimode) do - pipeworks.tube_inject_item(s, s, split.velocity, split.itemstack, self.owner) - end - -- remove ourself now the splits are sent - self:remove() return + else + velocity = vector.multiply(velocity, -1) + self:set_pos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1))) + self:set_velocity(velocity) end + elseif is_multimode(multimode) then + -- create new stacks according to returned data. + local s = self.start_pos + for _, split in ipairs(multimode) do + pipeworks.tube_inject_item(s, s, split.velocity, split.itemstack, self.owner) + end + -- remove ourself now the splits are sent + self:remove() + return + end - if new_velocity and not vector.equals(velocity, new_velocity) then - local nvelr = math.abs(new_velocity.x + new_velocity.y + new_velocity.z) - self:set_pos(vector.add(self.start_pos, vector.multiply(new_velocity, (moved_by - 1) / nvelr))) - self:set_velocity(new_velocity) - end + if new_velocity and not vector.equals(velocity, new_velocity) then + local nvelr = math.abs(new_velocity.x + new_velocity.y + new_velocity.z) + self:set_pos(vector.add(self.start_pos, vector.multiply(new_velocity, (moved_by - 1) / nvelr))) + self:set_velocity(new_velocity) end end }) From 90425fde95d410ccd39479665ec39a03c9780328 Mon Sep 17 00:00:00 2001 From: OgelGames Date: Mon, 23 May 2022 02:28:21 +1000 Subject: [PATCH 20/40] fix broken shift-clicking in wielder formspec fixes #34 --- wielder.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wielder.lua b/wielder.lua index 8b66df5..9aac1a2 100644 --- a/wielder.lua +++ b/wielder.lua @@ -23,9 +23,9 @@ local function set_wielder_formspec(data, meta) "item_image[0.5,0.5;1,1;"..data.name_base.."_off]".. "label[1.5,1;"..minetest.formspec_escape(data.description).."]".. list_background .. - "list[current_name;"..minetest.formspec_escape(data.wield_inv_name)..";"..((10-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]".. + "list[context;"..minetest.formspec_escape(data.wield_inv_name)..";"..((10-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]".. pipeworks.fs_helpers.get_inv((2+data.wield_inv_height)) .. - "listring[context;main]" .. + "listring[context;"..minetest.formspec_escape(data.wield_inv_name).."]" .. "listring[current_player;main]" ) meta:set_string("infotext", data.description) From 7b15bdbd1f46f4a804dfb0c5a3570081a70b8db0 Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Tue, 24 May 2022 19:13:41 -0400 Subject: [PATCH 21/40] Add configurable globalstep interval (#32) * Add configurable globalstep interval * Add warning for high globalstep interval * Lower maximum globalstep interval With no accelerator tubes, 0.8 can handle item movement speeds even with lag. --- default_settings.lua | 8 ++++---- init.lua | 3 +++ luaentity.lua | 35 +++++++++++++++++++++++++++++------ settingtypes.txt | 7 ++++++- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/default_settings.lua b/default_settings.lua index 975b1d6..6bf0a67 100644 --- a/default_settings.lua +++ b/default_settings.lua @@ -28,6 +28,7 @@ local settings = { drop_on_routing_fail = false, delete_item_on_clearobject = true, use_real_entities = true, + entity_update_interval = 0, } pipeworks.toggles = {} @@ -63,10 +64,9 @@ pipeworks.toggles.finite_water = nil for name, value in pairs(settings) do local setting_type = type(value) if setting_type == "boolean" then - pipeworks[name] = minetest.settings:get_bool(prefix..name) - if pipeworks[name] == nil then - pipeworks[name] = value - end + pipeworks[name] = minetest.settings:get_bool(prefix..name, value) + elseif setting_type == "number" then + pipeworks[name] = tonumber(minetest.settings:get(prefix..name) or value) else pipeworks[name] = value end diff --git a/init.lua b/init.lua index b9d95b0..ed011ba 100644 --- a/init.lua +++ b/init.lua @@ -32,6 +32,9 @@ end if pipeworks.toggles.pipe_mode == "pressure" then minetest.log("warning", "pipeworks pressure logic mode comes with caveats and differences in behaviour, you have been warned!") end +if pipeworks.entity_update_interval >= 0.2 and pipeworks.enable_accelerator_tube then + minetest.log("warning", "pipeworks accelerator tubes will not entirely work with an entity update interval 0.2 or above.") +end -- Random variables diff --git a/luaentity.lua b/luaentity.lua index 27799dd..9baea55 100644 --- a/luaentity.lua +++ b/luaentity.lua @@ -382,13 +382,36 @@ local move_entities_globalstep_part2 = function(dtime) end end -local handle_active_blocks_timer = 0.1 +-- dtime after which there is an update (or skip). +local dtime_threshold = pipeworks.entity_update_interval +-- Accumulated dtime since last update (or skip). +local dtime_accum = 0 +-- Delayed dtime accumulated due to skipped updates. +local dtime_delayed = 0 +local skip_update = false minetest.register_globalstep(function(dtime) - handle_active_blocks_timer = handle_active_blocks_timer + dtime - if dtime < 0.2 or handle_active_blocks_timer >= (dtime * 3) then - handle_active_blocks_timer = 0.1 - move_entities_globalstep_part1(dtime) - move_entities_globalstep_part2(dtime) + if dtime >= 0.2 and dtime_delayed < 1 then + -- Reduce activity when the server is lagging. + skip_update = true end + + dtime_accum = dtime_accum + dtime + if dtime_accum < dtime_threshold then + return + end + + if skip_update then + dtime_delayed = dtime_delayed + dtime_accum + skip_update = false + else + move_entities_globalstep_part1(dtime_accum + dtime_delayed) + move_entities_globalstep_part2(dtime_accum + dtime_delayed) + dtime_delayed = 0 + end + + -- Tune the threshold so that the average interval is pipeworks.entity_update_interval. + dtime_threshold = math.max(dtime_threshold + (pipeworks.entity_update_interval - dtime_accum) / 10, 0) + + dtime_accum = 0 end) diff --git a/settingtypes.txt b/settingtypes.txt index 3a6cbf4..ba25914 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -78,4 +78,9 @@ pipeworks_delete_item_on_clearobject (Delete Item On Clearobject) bool true #Use real visible entities in tubes within active areas. #When disabled, tubes are made opaque. -pipeworks_use_real_entities (Use real entities) bool true +pipeworks_use_real_entities (Use Real Entities) bool true + +#Target interval between tube entity steps. +#A high value may cause issues with tube entity visuals. +#A value 0.2 or above may cause issues with accelerator tubes. +pipeworks_entity_update_interval (Entity Update Interval) float 0 0 0.8 From 75894355d4f7b043dcf881cd8b39bd2b883995c8 Mon Sep 17 00:00:00 2001 From: SX <50966843+S-S-X@users.noreply.github.com> Date: Thu, 23 Jun 2022 19:06:01 +0300 Subject: [PATCH 22/40] Use on_repair when repairing tube (#37) * Use on_repair when repairing tube * Use tube.on_repair * Verify was_node registration --- routing_tubes.lua | 25 ++++++++++++++++++------- teleport_tube.lua | 12 ++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/routing_tubes.lua b/routing_tubes.lua index 5fc1d82..7593322 100644 --- a/routing_tubes.lua +++ b/routing_tubes.lua @@ -64,28 +64,39 @@ pipeworks.register_tube("pipeworks:broken_tube", { local itemstack = puncher:get_wielded_item() local wieldname = itemstack:get_name() local playername = puncher:get_player_name() - local log_msg = playername.." struck a broken tube at "..minetest.pos_to_string(pos).."\n" + local log_msg = playername.." struck a broken tube at "..minetest.pos_to_string(pos).."\n " local meta = minetest.get_meta(pos) local was_node = minetest.deserialize(meta:get_string("the_tube_was")) if not was_node then - pipeworks.logger(log_msg.." but it can't be repaired.") + pipeworks.logger(log_msg.."but it can't be repaired.") return end if not pipeworks.check_and_wear_hammer(puncher) then if wieldname == "" then - pipeworks.logger(log_msg.." by hand. It's not very effective.") + pipeworks.logger(log_msg.."by hand. It's not very effective.") if minetest.settings:get_bool("enable_damage") then minetest.chat_send_player(playername,S("Broken tubes may be a bit sharp. Perhaps try with a hammer?")) puncher:set_hp(puncher:get_hp()-1) end else - pipeworks.logger(log_msg.." with "..wieldname.." but that tool is too weak.") + pipeworks.logger(log_msg.."with "..wieldname.." but that tool is too weak.") end return end - pipeworks.logger(log_msg.." with "..wieldname.." to repair it.") - minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 }) - pipeworks.scan_for_tube_objects(pos) + log_msg = log_msg.."with "..wieldname.." to repair it" + local nodedef = minetest.registered_nodes[was_node.name] + if nodedef then + pipeworks.logger(log_msg..".") + if nodedef.tube and nodedef.tube.on_repair then + 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 + else + pipeworks.logger(log_msg.." but original node "..was_node.name.." is not registered anymore.") + minetest.chat_send_player(playername, S("This tube cannot be repaired.")) + end end } }) diff --git a/teleport_tube.lua b/teleport_tube.lua index 7250045..ad6a51c 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -184,6 +184,18 @@ pipeworks.register_tube("pipeworks:teleport_tube", { pos.y = target[d].y pos.z = target[d].z return pipeworks.meseadjlist + end, + on_repair = function(pos, node) + local meta = minetest.get_meta(pos) + local channel = meta:get_string("channel") + minetest.swap_node(pos, { name = node.name, param2 = node.param2 }) + pipeworks.scan_for_tube_objects(pos) + if channel ~= "" then + local can_receive = meta:get_int("can_receive") + set_tube(pos, channel, can_receive) + local cr_description = (can_receive == 1) and "sending and receiving" or "sending" + meta:set_string("infotext", S("Teleportation Tube @1 on '@2'", cr_description, channel)) + end end }, on_construct = function(pos) From 1823690daded9ee94be2e71cd7f39772fd09d405 Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Sat, 13 Aug 2022 16:22:53 -0400 Subject: [PATCH 23/40] Store teleport tube DB in mod storage (#40) * Store teleport tube DB in mod storage * Prevent overwriting of tube DB backup file * Remove backup code * Slightly improve storage reading code * Log DB migration to mod storage * Add migration note in README * Improve pipeworks.logger --- README | 4 +++ init.lua | 2 +- teleport_tube.lua | 90 +++++++++++++++++++++++++++++++---------------- 3 files changed, 65 insertions(+), 31 deletions(-) diff --git a/README b/README index 4af070d..2c23c9f 100644 --- a/README +++ b/README @@ -20,3 +20,7 @@ This mod is a work in progress. Please note that owing to the nature of this mod, I have opted to use 64px textures. Anything less just looks terrible. + +The teleport tube database used to kept in a file named 'teleport_tubes'. +The database is now kept in mod storage. The migration from 'teleport_tubes' is +automatic. The old file is then kept around but is not used at all. diff --git a/init.lua b/init.lua index ed011ba..08c0875 100644 --- a/init.lua +++ b/init.lua @@ -128,7 +128,7 @@ function pipeworks.replace_name(tbl,tr,name) end pipeworks.logger = function(msg) - print("[pipeworks] "..msg) + minetest.log("action", "[pipeworks] "..msg) end ------------------------------------------- diff --git a/teleport_tube.lua b/teleport_tube.lua index ad6a51c..3dffdf5 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -1,8 +1,9 @@ local S = minetest.get_translator("pipeworks") -local filename=minetest.get_worldpath() .. "/teleport_tubes" +local filename=minetest.get_worldpath() .. "/teleport_tubes" -- Only used for backward-compat +local storage=minetest.get_mod_storage() local tp_tube_db = nil -- nil forces a read -local tp_tube_db_version = 2.0 +local tp_tube_db_version = 3.0 -- cached rceiver list: hash(pos) => {receivers} local cache = {} @@ -12,47 +13,78 @@ local function hash(pos) end local function save_tube_db() - local file, err = io.open(filename, "w") - if file then - tp_tube_db.version = tp_tube_db_version - file:write(minetest.serialize(tp_tube_db)) - tp_tube_db.version = nil - io.close(file) - else - error(err) - end -- reset tp-tube cache cache = {} + + local fields = {version = tp_tube_db_version} + for key, val in pairs(tp_tube_db) do + fields[key] = minetest.serialize(val) + end + storage:from_table({fields = fields}) +end + +local function save_tube_db_entry(hash) + -- reset tp-tube cache + cache = {} + + local val = tp_tube_db[hash] + storage:set_string(hash, val and minetest.serialize(val) or "") end local function migrate_tube_db() + local old_version = tp_tube_db.version or 0 + tp_tube_db.version = nil + if old_version < 2.0 then local tmp_db = {} - tp_tube_db.version = nil for _, val in pairs(tp_tube_db) do if(val.channel ~= "") then -- skip unconfigured tubes tmp_db[hash(val)] = val end end tp_tube_db = tmp_db - save_tube_db() + end + save_tube_db() end local function read_tube_db() - local file = io.open(filename, "r") - if file ~= nil then + local file = not storage:contains("version") and io.open(filename, "r") + if not file then + tp_tube_db = {} + + for key, val in pairs(storage:to_table().fields) do + if tonumber(key) then + tp_tube_db[key] = minetest.deserialize(val) + elseif key == "version" then + tp_tube_db.version = tonumber(val) + else + error("Unknown field in teleport tube DB: " .. key) + end + end + + if tp_tube_db.version == nil then + tp_tube_db.version = tp_tube_db_version + storage:set_string("version", tp_tube_db.version) + elseif tp_tube_db.version > tp_tube_db_version then + error("Cannot read teleport tube DB of version " .. tp_tube_db.version) + end + else local file_content = file:read("*all") io.close(file) + pipeworks.logger("Moving teleport tube DB into mod storage from " .. filename) + if file_content and file_content ~= "" then tp_tube_db = minetest.deserialize(file_content) - if(not tp_tube_db.version or tonumber(tp_tube_db.version) < tp_tube_db_version) then - migrate_tube_db() - end - tp_tube_db.version = nil -- we add it back when saving - return tp_tube_db -- we read sucessfully + else + tp_tube_db = {version = 2.0} end end - tp_tube_db = {} + + if(not tp_tube_db.version or tonumber(tp_tube_db.version) < tp_tube_db_version) then + migrate_tube_db() + end + tp_tube_db.version = nil + return tp_tube_db end @@ -69,7 +101,7 @@ local function set_tube(pos, channel, can_receive) if tube then tube.channel = channel tube.cr = can_receive - save_tube_db() + save_tube_db_entry(hash) return end @@ -88,13 +120,14 @@ local function set_tube(pos, channel, can_receive) end tp_tube_db[hash] = {x=pos.x,y=pos.y,z=pos.z,channel=channel,cr=can_receive} - save_tube_db() + save_tube_db_entry(hash) end local function remove_tube(pos) local tubes = tp_tube_db or read_tube_db() - tubes[hash(pos)] = nil - save_tube_db() + local hash = hash(pos) + tubes[hash] = nil + save_tube_db_entry(hash) end local function read_node_with_vm(pos) @@ -114,7 +147,6 @@ local function get_receivers(pos, channel) local tubes = tp_tube_db or read_tube_db() local receivers = {} - local dirty = false for key, val in pairs(tubes) do -- skip all non-receivers and the tube that it came from as early as possible, as this is called often if (val.cr == 1 and val.channel == channel and (val.x ~= pos.x or val.y ~= pos.y or val.z ~= pos.z)) then @@ -125,13 +157,10 @@ local function get_receivers(pos, channel) table.insert(receivers, val) else tp_tube_db[key] = nil - dirty = true + save_tube_db_entry(key) end end end - if dirty then - save_tube_db() - end -- cache the result for next time cache[hash] = receivers return receivers @@ -290,6 +319,7 @@ end pipeworks.tptube = { hash = hash, save_tube_db = save_tube_db, + save_tube_db_entry = save_tube_db_entry, get_db = function() return tp_tube_db or read_tube_db() end, set_tube = set_tube, update_meta = update_meta, From 54243764e0551371afeeade775fbb18dd81c4dc9 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Sat, 13 Aug 2022 23:59:46 -0400 Subject: [PATCH 24/40] prevent tubes from connecting to the front of furnaces to match chests --- compat-furnaces.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compat-furnaces.lua b/compat-furnaces.lua index 432aff1..c4cbd86 100644 --- a/compat-furnaces.lua +++ b/compat-furnaces.lua @@ -59,7 +59,7 @@ local override = { end end, input_inventory = "dst", - connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1} + connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} }, after_place_node = pipeworks.after_place, @@ -110,7 +110,7 @@ local override_active = { end end, input_inventory = "dst", - connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1} + connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1} }, after_place_node = pipeworks.after_place, From b6c02ac8deb26bbd73b9bbb94c840e136d224e6e Mon Sep 17 00:00:00 2001 From: Luke aka SwissalpS Date: Tue, 16 Aug 2022 00:30:42 +0200 Subject: [PATCH 25/40] typo fix --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 2c23c9f..ea834f2 100644 --- a/README +++ b/README @@ -21,6 +21,6 @@ This mod is a work in progress. Please note that owing to the nature of this mod, I have opted to use 64px textures. Anything less just looks terrible. -The teleport tube database used to kept in a file named 'teleport_tubes'. +The teleport tube database used to be kept in a file named 'teleport_tubes'. The database is now kept in mod storage. The migration from 'teleport_tubes' is automatic. The old file is then kept around but is not used at all. From 65cea1e33cfcc6f839f7b65aca566d3abc7346d8 Mon Sep 17 00:00:00 2001 From: fluxionary <25628292+fluxionary@users.noreply.github.com> Date: Fri, 16 Sep 2022 16:16:58 -0700 Subject: [PATCH 26/40] check if target is protected before trying to break/place a node, so as not to trigger protection violations (#42) --- wielder.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wielder.lua b/wielder.lua index 9aac1a2..dd4228c 100644 --- a/wielder.lua +++ b/wielder.lua @@ -336,6 +336,14 @@ if pipeworks.enable_node_breaker then masquerade_as_owner = true, sneak = false, act = function(virtplayer, pointed_thing) + local player_name = virtplayer:get_player_name() + if ( + minetest.is_protected(pointed_thing.above, player_name) or + minetest.is_protected(pointed_thing.under, player_name) + ) then + return + end + --local dname = "nodebreaker.act() " local wieldstack = virtplayer:get_wielded_item() local oldwieldstack = ItemStack(wieldstack) @@ -427,6 +435,14 @@ if pipeworks.enable_deployer then masquerade_as_owner = true, sneak = false, act = function(virtplayer, pointed_thing) + local player_name = virtplayer:get_player_name() + if ( + minetest.is_protected(pointed_thing.above, player_name) or + minetest.is_protected(pointed_thing.under, player_name) + ) then + return + end + local wieldstack = virtplayer:get_wielded_item() virtplayer:set_wielded_item((minetest.registered_items[wieldstack:get_name()] or {on_place=minetest.item_place}).on_place(wieldstack, virtplayer, pointed_thing) or wieldstack) end, From e45eca76e16ee68a0454799b8035aa2233cb72de Mon Sep 17 00:00:00 2001 From: fluxionary <25628292+fluxionary@users.noreply.github.com> Date: Sat, 17 Sep 2022 16:03:55 -0700 Subject: [PATCH 27/40] check if machine is protected before trying to break/place a node (#43) * check if target is protected before trying to break/place a node, so as not to trigger protection violations * check whether the machine is protected, not the target --- wielder.lua | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/wielder.lua b/wielder.lua index dd4228c..6bde2df 100644 --- a/wielder.lua +++ b/wielder.lua @@ -336,11 +336,7 @@ if pipeworks.enable_node_breaker then masquerade_as_owner = true, sneak = false, act = function(virtplayer, pointed_thing) - local player_name = virtplayer:get_player_name() - if ( - minetest.is_protected(pointed_thing.above, player_name) or - minetest.is_protected(pointed_thing.under, player_name) - ) then + if minetest.is_protected(vector.add(virtplayer:get_pos(), assumed_eye_pos), virtplayer:get_player_name()) then return end @@ -435,11 +431,7 @@ if pipeworks.enable_deployer then masquerade_as_owner = true, sneak = false, act = function(virtplayer, pointed_thing) - local player_name = virtplayer:get_player_name() - if ( - minetest.is_protected(pointed_thing.above, player_name) or - minetest.is_protected(pointed_thing.under, player_name) - ) then + if minetest.is_protected(vector.add(virtplayer:get_pos(), assumed_eye_pos), virtplayer:get_player_name()) then return end From b190d29d21ace3c283ca56547915af7d6430fc2c Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Mon, 19 Sep 2022 20:21:34 -0400 Subject: [PATCH 28/40] fix https://github.com/mt-mods/pipeworks/issues/44 --- init.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 08c0875..8d698d6 100644 --- a/init.lua +++ b/init.lua @@ -178,8 +178,7 @@ if pipeworks.enable_redefines and (minetest.get_modpath("default") or minetest.g dofile(pipeworks.modpath.."/compat-furnaces.lua") end if pipeworks.enable_autocrafter then dofile(pipeworks.modpath.."/autocrafter.lua") end -if pipeworks.enable_lua_tube and - (minetest.get_modpath("mesecons") or minetest.get_modpath("digilines")) then +if pipeworks.enable_lua_tube and minetest.get_modpath("mesecons") then dofile(pipeworks.modpath.."/lua_tube.lua") end From 8c251800db1d9d190829cfdeea8cf339bcdecc89 Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Wed, 21 Sep 2022 17:53:42 -0400 Subject: [PATCH 29/40] Store teleport tube DB more compactly (#45) --- teleport_tube.lua | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/teleport_tube.lua b/teleport_tube.lua index 3dffdf5..c2cc52e 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -3,7 +3,7 @@ local filename=minetest.get_worldpath() .. "/teleport_tubes" -- Only used for ba local storage=minetest.get_mod_storage() local tp_tube_db = nil -- nil forces a read -local tp_tube_db_version = 3.0 +local tp_tube_db_version = 4 -- cached rceiver list: hash(pos) => {receivers} local cache = {} @@ -12,13 +12,29 @@ local function hash(pos) return string.format("%.30g", minetest.hash_node_position(pos)) end +-- New entry format: ':' + +local function serialize_tube_db_entry(entry) + return entry.cr .. ":" .. entry.channel +end + +local function deserialize_tube_db_entry(hash, str) + local sep = str:find(":", 2, true) + if not sep then return minetest.deserialize(str) end + local cr = tonumber(str:sub(1, sep - 1)) + if not cr then return minetest.deserialize(str) end + local channel = str:sub(sep + 1) + local pos = minetest.get_position_from_hash(tonumber(hash)) + return {x = pos.x, y = pos.y, z = pos.z, cr = cr, channel = channel} +end + local function save_tube_db() -- reset tp-tube cache cache = {} local fields = {version = tp_tube_db_version} for key, val in pairs(tp_tube_db) do - fields[key] = minetest.serialize(val) + fields[key] = serialize_tube_db_entry(val) end storage:from_table({fields = fields}) end @@ -28,7 +44,7 @@ local function save_tube_db_entry(hash) cache = {} local val = tp_tube_db[hash] - storage:set_string(hash, val and minetest.serialize(val) or "") + storage:set_string(hash, val and serialize_tube_db_entry(val) or "") end local function migrate_tube_db() @@ -53,7 +69,7 @@ local function read_tube_db() for key, val in pairs(storage:to_table().fields) do if tonumber(key) then - tp_tube_db[key] = minetest.deserialize(val) + tp_tube_db[key] = deserialize_tube_db_entry(key, val) elseif key == "version" then tp_tube_db.version = tonumber(val) else From 5345fe7af3974dab9cdbbd694956780bfa78ed67 Mon Sep 17 00:00:00 2001 From: OgelGames Date: Fri, 11 Nov 2022 23:14:08 +1100 Subject: [PATCH 30/40] Prevent vacuum tubes breaking themselves and refactor code (#51) also bumps `min_minetest_version` to 5.4.0 --- crafts.lua | 18 +++++ init.lua | 20 ++++-- mod.conf | 2 +- vacuum_tubes.lua | 173 +++++++++++++++++++++++------------------------ 4 files changed, 118 insertions(+), 95 deletions(-) diff --git a/crafts.lua b/crafts.lua index 6d261a0..54e2d6a 100644 --- a/crafts.lua +++ b/crafts.lua @@ -298,6 +298,24 @@ if pipeworks.enable_mese_tube then }) end +if pipeworks.enable_sand_tube then + minetest.register_craft( { + output = "pipeworks:sand_tube_1 2", + recipe = { + {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"}, + {"group:sand", "group:sand", "group:sand"}, + {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"} + }, + }) + + minetest.register_craft( { + output = "pipeworks:sand_tube_1", + recipe = { + {"group:sand", "pipeworks:tube_1", "group:sand"}, + }, + }) +end + if pipeworks.enable_mese_sand_tube then minetest.register_craft( { output = "pipeworks:mese_sand_tube_1 2", diff --git a/init.lua b/init.lua index 8d698d6..8622c6f 100644 --- a/init.lua +++ b/init.lua @@ -153,7 +153,6 @@ dofile(pipeworks.modpath.."/flowing_logic.lua") dofile(pipeworks.modpath.."/tube_registration.lua") dofile(pipeworks.modpath.."/routing_tubes.lua") dofile(pipeworks.modpath.."/sorting_tubes.lua") -dofile(pipeworks.modpath.."/vacuum_tubes.lua") dofile(pipeworks.modpath.."/signal_tubes.lua") dofile(pipeworks.modpath.."/decorative_tubes.lua") dofile(pipeworks.modpath.."/filter-injector.lua") @@ -170,17 +169,28 @@ dofile(pipeworks.modpath..logicdir.."abms.lua") dofile(pipeworks.modpath..logicdir.."abm_register.lua") dofile(pipeworks.modpath..logicdir.."flowable_node_registry_install.lua") -if pipeworks.enable_pipes then dofile(pipeworks.modpath.."/pipes.lua") end -if pipeworks.enable_teleport_tube then dofile(pipeworks.modpath.."/teleport_tube.lua") end -if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end +if pipeworks.enable_pipes then + dofile(pipeworks.modpath.."/pipes.lua") +end +if pipeworks.enable_teleport_tube then + dofile(pipeworks.modpath.."/teleport_tube.lua") +end +if pipeworks.enable_pipe_devices then + dofile(pipeworks.modpath.."/devices.lua") +end if pipeworks.enable_redefines and (minetest.get_modpath("default") or minetest.get_modpath("hades_core")) then dofile(pipeworks.modpath.."/compat-chests.lua") dofile(pipeworks.modpath.."/compat-furnaces.lua") end -if pipeworks.enable_autocrafter then dofile(pipeworks.modpath.."/autocrafter.lua") end +if pipeworks.enable_autocrafter then + dofile(pipeworks.modpath.."/autocrafter.lua") +end if pipeworks.enable_lua_tube and minetest.get_modpath("mesecons") then dofile(pipeworks.modpath.."/lua_tube.lua") end +if pipeworks.enable_sand_tube or pipeworks.enable_mese_sand_tube then + dofile(pipeworks.modpath.."/vacuum_tubes.lua") +end dofile(pipeworks.modpath.."/crafts.lua") diff --git a/mod.conf b/mod.conf index 2b390b6..cab78e8 100644 --- a/mod.conf +++ b/mod.conf @@ -2,4 +2,4 @@ name = pipeworks description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them. depends = basic_materials optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests -min_minetest_version = 5.2.0 +min_minetest_version = 5.4.0 diff --git a/vacuum_tubes.lua b/vacuum_tubes.lua index 684e6cf..91ed02b 100644 --- a/vacuum_tubes.lua +++ b/vacuum_tubes.lua @@ -1,4 +1,37 @@ + local S = minetest.get_translator("pipeworks") + +local enable_max = minetest.settings:get_bool("pipeworks_enable_items_per_tube_limit", true) +local max_items = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30 +max_items = math.ceil(max_items / 2) -- Limit vacuuming to half the max limit + +local function vacuum(pos, radius) + radius = radius + 0.5 + local min_pos = vector.subtract(pos, radius) + local max_pos = vector.add(pos, radius) + local count = 0 + for _, obj in pairs(minetest.get_objects_in_area(min_pos, max_pos)) do + local entity = obj:get_luaentity() + if entity and entity.name == "__builtin:item" then + if entity.itemstring ~= "" then + pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), entity.itemstring) + entity.itemstring = "" + count = count + 1 + end + obj:remove() + if enable_max and count >= max_items then + return -- Don't break tube by vacuuming too many items + end + end + end +end + +local function set_timer(pos) + local timer = minetest.get_node_timer(pos) + -- Randomize timer so not all tubes vacuum at the same time + timer:start(math.random(10, 20) * 0.1) +end + if pipeworks.enable_sand_tube then pipeworks.register_tube("pipeworks:sand_tube", { description = S("Vacuuming Pneumatic Tube Segment"), @@ -6,102 +39,64 @@ if pipeworks.enable_sand_tube then short = "pipeworks_sand_tube_short.png", noctr = {"pipeworks_sand_tube_noctr.png"}, plain = {"pipeworks_sand_tube_plain.png"}, - ends = {"pipeworks_sand_tube_end.png"}, - node_def = {groups = {vacuum_tube = 1}}, - }) - - minetest.register_craft( { - output = "pipeworks:sand_tube_1 2", - recipe = { - {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"}, - {"group:sand", "group:sand", "group:sand"}, - {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"} - }, - }) - - minetest.register_craft( { - output = "pipeworks:sand_tube_1", - recipe = { - {"group:sand", "pipeworks:tube_1", "group:sand"}, + ends = {"pipeworks_sand_tube_end.png"}, + node_def = { + groups = {vacuum_tube = 1}, + on_construct = set_timer, + on_timer = function(pos, elapsed) + vacuum(pos, 2) + set_timer(pos) + end, }, }) end if pipeworks.enable_mese_sand_tube then - pipeworks.register_tube("pipeworks:mese_sand_tube", { - description = S("Adjustable Vacuuming Pneumatic Tube Segment"), - inventory_image = "pipeworks_mese_sand_tube_inv.png", - short = "pipeworks_mese_sand_tube_short.png", - noctr = {"pipeworks_mese_sand_tube_noctr.png"}, - plain = {"pipeworks_mese_sand_tube_plain.png"}, - ends = {"pipeworks_mese_sand_tube_end.png"}, - node_def = { - groups = {vacuum_tube = 1}, - on_construct = function(pos) - local meta = minetest.get_meta(pos) - local size = "6.0,2.4" - meta:set_int("dist", 0) - meta:set_string("formspec", - "size["..size.."]".. - pipeworks.fs_helpers.get_prepends(size) .. - "image[0.2,0;1,1;pipeworks_mese_sand_tube_inv.png]".. - "label[1.2,0.2;"..S("Adjustable Vacuuming Tube").."]".. - "field[0.5,1.6;2.1,1;dist;"..S("Radius")..";${dist}]".. - "button[2.3,1.3;1.5,1;set_dist;"..S("Set").."]".. - "button_exit[3.8,1.3;2,1;close;"..S("Close").."]") - meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment")) - end, - on_receive_fields = function(pos,formname,fields,sender) - if (fields.quit and not fields.key_enter_field) - or (fields.key_enter_field ~= "dist" and not fields.set_dist) - or not pipeworks.may_configure(pos, sender) then - return - end + local formspec = "formspec_version[2]size[8,3]".. + pipeworks.fs_helpers.get_prepends("8,3").. + "image[0.5,0.3;1,1;pipeworks_mese_sand_tube_inv.png]".. + "label[1.75,0.8;"..S("Adjustable Vacuuming Tube").."]".. + "field[0.5,1.7;5,0.8;dist;"..S("Radius")..";${dist}]".. + "button_exit[5.5,1.7;2,0.8;save;"..S("Save").."]" - local meta = minetest.get_meta(pos) - local dist = tonumber(fields.dist) - if dist then - dist = math.max(0, dist) - dist = math.min(8, dist) - meta:set_int("dist", dist) - meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment (@1m)", dist)) - end - end, - }, + pipeworks.register_tube("pipeworks:mese_sand_tube", { + description = S("Adjustable Vacuuming Tube"), + inventory_image = "pipeworks_mese_sand_tube_inv.png", + short = "pipeworks_mese_sand_tube_short.png", + noctr = {"pipeworks_mese_sand_tube_noctr.png"}, + plain = {"pipeworks_mese_sand_tube_plain.png"}, + ends = {"pipeworks_mese_sand_tube_end.png"}, + node_def = { + groups = {vacuum_tube = 1}, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_int("dist", 2) + meta:set_string("formspec", formspec) + meta:set_string("infotext", S("Adjustable Vacuuming Tube (@1m)", 2)) + set_timer(pos) + end, + on_timer = function(pos, elapsed) + local radius = minetest.get_meta(pos):get_int("dist") + vacuum(pos, radius) + set_timer(pos) + end, + on_receive_fields = function(pos, _, fields, sender) + if not fields.dist or not pipeworks.may_configure(pos, sender) then + return + end + local meta = minetest.get_meta(pos) + local dist = math.min(math.max(tonumber(fields.dist) or 0, 0), 8) + meta:set_int("dist", dist) + meta:set_string("infotext", S("Adjustable Vacuuming Tube (@1m)", dist)) + end, + }, }) end -local function vacuum(pos, radius) - radius = radius + 0.5 - for _, object in pairs(minetest.get_objects_inside_radius(pos, math.sqrt(3) * radius)) do - local lua_entity = object:get_luaentity() - if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then - local obj_pos = object:get_pos() - local minpos = vector.subtract(pos, radius) - local maxpos = vector.add(pos, radius) - if obj_pos.x >= minpos.x and obj_pos.x <= maxpos.x - and obj_pos.y >= minpos.y and obj_pos.y <= maxpos.y - and obj_pos.z >= minpos.z and obj_pos.z <= maxpos.z then - if lua_entity.itemstring ~= "" then - pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), lua_entity.itemstring) - lua_entity.itemstring = "" - end - object:remove() - end - end - end -end - -minetest.register_abm({nodenames = {"group:vacuum_tube"}, - interval = 1, - chance = 1, - label = "Vacuum tubes", - action = function(pos, node, active_object_count, active_object_count_wider) - if node.name:find("pipeworks:sand_tube") then - vacuum(pos, 2) - else - local radius = minetest.get_meta(pos):get_int("dist") - vacuum(pos, radius) - end - end +minetest.register_lbm({ + label = "Vacuum tube node timer starter", + name = "pipeworks:vacuum_tube_start", + nodenames = {"group:vacuum_tube"}, + run_at_every_load = false, + action = set_timer, }) From 5e9bfa049b60805a73250dd495a4755f37247346 Mon Sep 17 00:00:00 2001 From: OgelGames Date: Fri, 11 Nov 2022 23:20:28 +1100 Subject: [PATCH 31/40] Add digilines to teleport tube and refactor code (#49) --- teleport_tube.lua | 538 +++++++++++++++++++++++----------------------- 1 file changed, 270 insertions(+), 268 deletions(-) diff --git a/teleport_tube.lua b/teleport_tube.lua index c2cc52e..74a610a 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -1,206 +1,304 @@ + local S = minetest.get_translator("pipeworks") -local filename=minetest.get_worldpath() .. "/teleport_tubes" -- Only used for backward-compat -local storage=minetest.get_mod_storage() +local filename = minetest.get_worldpath().."/teleport_tubes" -- Only used for backward-compat +local storage = minetest.get_mod_storage() -local tp_tube_db = nil -- nil forces a read -local tp_tube_db_version = 4 +local has_digilines = minetest.get_modpath("digilines") --- cached rceiver list: hash(pos) => {receivers} -local cache = {} +-- V1: Serialized text file indexed by vector position. +-- V2: Serialized text file indexed by hash position. +-- V3: Mod storage using serialized tables. +-- V4: Mod storage using ":" format. +local tube_db_version = 4 +local tube_db = {} +local receiver_cache = {} -local function hash(pos) - return string.format("%.30g", minetest.hash_node_position(pos)) +local function hash_pos(pos) + vector.round(pos) + return string.format("%.0f", minetest.hash_node_position(pos)) end --- New entry format: ':' - -local function serialize_tube_db_entry(entry) - return entry.cr .. ":" .. entry.channel +local function serialize_tube(tube) + return string.format("%d:%s", tube.cr, tube.channel) end -local function deserialize_tube_db_entry(hash, str) - local sep = str:find(":", 2, true) - if not sep then return minetest.deserialize(str) end - local cr = tonumber(str:sub(1, sep - 1)) - if not cr then return minetest.deserialize(str) end - local channel = str:sub(sep + 1) - local pos = minetest.get_position_from_hash(tonumber(hash)) - return {x = pos.x, y = pos.y, z = pos.z, cr = cr, channel = channel} +local function deserialize_tube(hash, str) + local sep = str:sub(2, 2) == ":" + local cr = tonumber(str:sub(1, 1)) + local channel = str:sub(3) + if sep and cr and channel then + local pos = minetest.get_position_from_hash(tonumber(hash)) + return {x = pos.x, y = pos.y, z = pos.z, cr = cr, channel = channel} + end end local function save_tube_db() - -- reset tp-tube cache - cache = {} - - local fields = {version = tp_tube_db_version} - for key, val in pairs(tp_tube_db) do - fields[key] = serialize_tube_db_entry(val) + receiver_cache = {} + local fields = {version = tube_db_version} + for key, val in pairs(tube_db) do + fields[key] = serialize_tube(val) end storage:from_table({fields = fields}) end -local function save_tube_db_entry(hash) - -- reset tp-tube cache - cache = {} +local function save_tube(hash) + local tube = tube_db[hash] + receiver_cache[tube.channel] = nil + storage:set_string(hash, serialize_tube(tube)) +end - local val = tp_tube_db[hash] - storage:set_string(hash, val and serialize_tube_db_entry(val) or "") +local function remove_tube(pos) + local hash = hash_pos(pos) + if tube_db[hash] then + receiver_cache[tube_db[hash].channel] = nil + tube_db[hash] = nil + storage:set_string(hash, "") + end end local function migrate_tube_db() - local old_version = tp_tube_db.version or 0 - tp_tube_db.version = nil - if old_version < 2.0 then - local tmp_db = {} - for _, val in pairs(tp_tube_db) do - if(val.channel ~= "") then -- skip unconfigured tubes - tmp_db[hash(val)] = val + if storage:get_int("version") == 3 then + for key, val in pairs(storage:to_table().fields) do + if tonumber(key) then + tube_db[key] = minetest.deserialize(val) + elseif key ~= "version" then + error("Unknown field in teleport tube database: "..key) end end - tp_tube_db = tmp_db + save_tube_db() + return + end + local file = io.open(filename, "r") + if file then + local content = file:read("*all") + io.close(file) + if content and content ~= "" then + tube_db = minetest.deserialize(content) + end + end + local version = tube_db.version or 0 + tube_db.version = nil + if version < 2 then + local tmp_db = {} + for _, val in pairs(tube_db) do + if val.channel ~= "" then -- Skip unconfigured tubes + tmp_db[hash_pos(val)] = val + end + end + tube_db = tmp_db end save_tube_db() end local function read_tube_db() - local file = not storage:contains("version") and io.open(filename, "r") - if not file then - tp_tube_db = {} - + local version = storage:get_int("version") + if version < tube_db_version then + migrate_tube_db() + elseif version > tube_db_version then + error("Cannot read teleport tube database of version "..version) + else for key, val in pairs(storage:to_table().fields) do if tonumber(key) then - tp_tube_db[key] = deserialize_tube_db_entry(key, val) - elseif key == "version" then - tp_tube_db.version = tonumber(val) - else - error("Unknown field in teleport tube DB: " .. key) + tube_db[key] = deserialize_tube(key, val) + elseif key ~= "version" then + error("Unknown field in teleport tube database: "..key) end end + end + tube_db.version = nil +end - if tp_tube_db.version == nil then - tp_tube_db.version = tp_tube_db_version - storage:set_string("version", tp_tube_db.version) - elseif tp_tube_db.version > tp_tube_db_version then - error("Cannot read teleport tube DB of version " .. tp_tube_db.version) +local function set_tube(pos, channel, cr) + local hash = hash_pos(pos) + local tube = tube_db[hash] + if tube then + if tube.channel ~= channel or tube.cr ~= cr then + tube.channel = channel + tube.cr = cr + save_tube(hash) end else - local file_content = file:read("*all") - io.close(file) - - pipeworks.logger("Moving teleport tube DB into mod storage from " .. filename) - - if file_content and file_content ~= "" then - tp_tube_db = minetest.deserialize(file_content) - else - tp_tube_db = {version = 2.0} - end + tube_db[hash] = {x = pos.x, y = pos.y, z = pos.z, channel = channel, cr = cr} + save_tube(hash) end - - if(not tp_tube_db.version or tonumber(tp_tube_db.version) < tp_tube_db_version) then - migrate_tube_db() - end - tp_tube_db.version = nil - - return tp_tube_db -end - --- debug formatter for coordinates used below -local fmt = function(pos) - return pos.x..", "..pos.y..", "..pos.z -end - --- updates or adds a tube -local function set_tube(pos, channel, can_receive) - local tubes = tp_tube_db or read_tube_db() - local hash = hash(pos) - local tube = tubes[hash] - if tube then - tube.channel = channel - tube.cr = can_receive - save_tube_db_entry(hash) - return - end - - -- we haven't found any tp tube to update, so lets add it - -- but sanity check that the hash has not already been inserted. - -- if so, complain very loudly and refuse the update so the player knows something is amiss. - -- to catch regressions of https://github.com/minetest-mods/pipeworks/issues/166 - local existing = tp_tube_db[hash] - if existing ~= nil then - local e = "error" - minetest.log(e, "pipeworks teleport tube update refused due to position hash collision") - minetest.log(e, "collided hash: "..hash) - minetest.log(e, "tried-to-place tube: "..fmt(pos)) - minetest.log(e, "existing tube: "..fmt(existing)) - return - end - - tp_tube_db[hash] = {x=pos.x,y=pos.y,z=pos.z,channel=channel,cr=can_receive} - save_tube_db_entry(hash) -end - -local function remove_tube(pos) - local tubes = tp_tube_db or read_tube_db() - local hash = hash(pos) - tubes[hash] = nil - save_tube_db_entry(hash) -end - -local function read_node_with_vm(pos) - local vm = VoxelManip() - local MinEdge, MaxEdge = vm:read_from_map(pos, pos) - local data = vm:get_data() - local area = VoxelArea:new({MinEdge = MinEdge, MaxEdge = MaxEdge}) - return minetest.get_name_from_content_id(data[area:index(pos.x, pos.y, pos.z)]) end local function get_receivers(pos, channel) - local hash = minetest.hash_node_position(pos) + local hash = hash_pos(pos) + local cache = receiver_cache[channel] or {} if cache[hash] then - -- re-use cached result return cache[hash] end - - local tubes = tp_tube_db or read_tube_db() local receivers = {} - for key, val in pairs(tubes) do - -- skip all non-receivers and the tube that it came from as early as possible, as this is called often - if (val.cr == 1 and val.channel == channel and (val.x ~= pos.x or val.y ~= pos.y or val.z ~= pos.z)) then - local is_loaded = (minetest.get_node_or_nil(val) ~= nil) - local node_name = is_loaded and minetest.get_node(pos).name or read_node_with_vm(val) - - if minetest.registered_nodes[node_name] and minetest.registered_nodes[node_name].is_teleport_tube then + for key, val in pairs(tube_db) do + if val.cr == 1 and val.channel == channel and not vector.equals(val, pos) then + minetest.load_area(val) + local node_name = minetest.get_node(val).name + if node_name:find("pipeworks:teleport_tube") then table.insert(receivers, val) else - tp_tube_db[key] = nil - save_tube_db_entry(key) + remove_tube(val) end end end - -- cache the result for next time cache[hash] = receivers + receiver_cache[channel] = cache return receivers end -local function update_meta(meta, can_receive) - meta:set_int("can_receive", can_receive and 1 or 0) - local cr_state = can_receive and "on" or "off" - local itext = S("Channels are public by default").."\n".. - S("Use : for fully private channels").."\n".. - S("Use \\; for private receivers") - local size = "8.5,4" - meta:set_string("formspec", - "formspec_version[2]".. - "size["..size.."]".. - pipeworks.fs_helpers.get_prepends(size) .. - "image[0.5,o;1,1;pipeworks_teleport_tube_inv.png]".. - "label[1.5,0.5;"..S("Teleporting Tube").."]".. - "field[0.5,1.6;4.3,0.75;channel;"..S("Channel")..";${channel}]".. - "button[4.8,1.6;1.5,0.75;set_channel;"..S("Set").."]".. - "label[7.0,0.5;"..S("Receive").."]".. - "image_button[7.0,0.75;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]".. - "button_exit[6.3,1.6;2,0.75;close;"..S("Close").."]".. - "label[0.5,2.7;"..itext.."]") +local help_text = S("Channels are public by default").."\n".. + S("Use : for fully private channels").."\n".. + S("Use \\; for private receivers") + +local size = has_digilines and "8,5.9" or "8,4.4" + +local formspec = "formspec_version[2]size["..size.."]".. + pipeworks.fs_helpers.get_prepends(size).. + "image[0.5,0.3;1,1;pipeworks_teleport_tube_inv.png]".. + "label[1.75,0.8;"..S("Teleporting Tube").."]".. + "field[0.5,1.7;5,0.8;channel;"..S("Channel")..";${channel}]".. + "button_exit[5.5,1.7;2,0.8;save;"..S("Save").."]".. + "label[6.5,0.6;"..S("Receive").."]".. + "label[0.5,2.8;"..help_text.."]" + +if has_digilines then + formspec = formspec.. + "field[0.5,4.6;5,0.8;digiline_channel;"..S("Digiline Channel")..";${digiline_channel}]".. + "button_exit[5.5,4.6;2,0.8;save;"..S("Save").."]" +end + +local function update_meta(meta) + local channel = meta:get_string("channel") + local cr = meta:get_int("can_receive") == 1 + if channel == "" then + meta:set_string("infotext", S("Unconfigured Teleportation Tube")) + else + local desc = cr and "sending and receiving" or "sending" + meta:set_string("infotext", S("Teleportation Tube @1 on '@2'", desc, channel)) + end + local state = cr and "on" or "off" + meta:set_string("formspec", formspec.. + "image_button[6.4,0.8;1,0.6;pipeworks_button_"..state.. + ".png;cr_"..state..";;;false;pipeworks_button_interm.png]") +end + +local function update_tube(pos, channel, cr, player_name) + local meta = minetest.get_meta(pos) + if meta:get_string("channel") == channel and meta:get_int("can_receive") == cr then + return + end + if channel == "" then + meta:set_string("channel", "") + meta:set_int("can_receive", cr) + remove_tube(pos) + return + end + local name, mode = channel:match("^([^:;]+)([:;])") + if name and mode and name ~= player_name then + if mode == ":" then + minetest.chat_send_player(player_name, + S("Sorry, channel '@1' is reserved for exclusive use by @2", channel, name)) + return + elseif mode == ";" and cr ~= 0 then + minetest.chat_send_player(player_name, + S("Sorry, receiving from channel '@1' is reserved for @2", channel, name)) + return + end + end + meta:set_string("channel", channel) + meta:set_int("can_receive", cr) + set_tube(pos, channel, cr) +end + +local function receive_fields(pos, _, fields, sender) + if not fields.channel or not pipeworks.may_configure(pos, sender) then + return + end + local meta = minetest.get_meta(pos) + local channel = fields.channel:trim() + local cr = meta:get_int("can_receive") + if fields.cr_on then + cr = 0 + elseif fields.cr_off then + cr = 1 + end + if has_digilines and fields.digiline_channel then + meta:set_string("digiline_channel", fields.digiline_channel) + end + update_tube(pos, channel, cr, sender:get_player_name()) + update_meta(meta) +end + +local function can_go(pos, node, velocity, stack) + velocity.x = 0 + velocity.y = 0 + velocity.z = 0 + local channel = minetest.get_meta(pos):get_string("channel") + if channel == "" then + return {} + end + local receivers = get_receivers(pos, channel) + if #receivers == 0 then + return {} + end + local target = receivers[math.random(1, #receivers)] + pos.x = target.x + pos.y = target.y + pos.z = target.z + return pipeworks.meseadjlist +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 + set_tube(pos, channel, meta:get_int("can_receive")) + end + update_meta(meta) +end + +local function digiline_action(pos, _, channel, msg) + local meta = minetest.get_meta(pos) + if channel ~= meta:get_string("digiline_channel") or type(msg) ~= "string" then + return + end + local name = meta:get_string("owner") + local cr = meta:get_int("can_receive") + update_tube(pos, msg, cr, name) + update_meta(meta) +end + +local def = { + tube = { + can_go = can_go, + on_repair = repair_tube, + }, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_int("can_receive", 1) -- Enabled by default + update_meta(meta) + end, + on_receive_fields = receive_fields, + on_destruct = remove_tube, +} + +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 = { + rules = pipeworks.digilines_rules, + }, + effector = { + rules = pipeworks.digilines_rules, + action = digiline_action, + } + } end pipeworks.register_tube("pipeworks:teleport_tube", { @@ -210,120 +308,14 @@ pipeworks.register_tube("pipeworks:teleport_tube", { plain = { "pipeworks_teleport_tube_plain.png" }, ends = { "pipeworks_teleport_tube_end.png" }, short = "pipeworks_teleport_tube_short.png", - node_def = { - is_teleport_tube = true, - tube = { - can_go = function(pos,node,velocity,stack) - velocity.x = 0 - velocity.y = 0 - velocity.z = 0 - - local channel = minetest.get_meta(pos):get_string("channel") - if channel == "" then return {} end - - local target = get_receivers(pos, channel) - if target[1] == nil then return {} end - - local d = math.random(1,#target) - pos.x = target[d].x - pos.y = target[d].y - pos.z = target[d].z - return pipeworks.meseadjlist - end, - on_repair = function(pos, node) - local meta = minetest.get_meta(pos) - local channel = meta:get_string("channel") - minetest.swap_node(pos, { name = node.name, param2 = node.param2 }) - pipeworks.scan_for_tube_objects(pos) - if channel ~= "" then - local can_receive = meta:get_int("can_receive") - set_tube(pos, channel, can_receive) - local cr_description = (can_receive == 1) and "sending and receiving" or "sending" - meta:set_string("infotext", S("Teleportation Tube @1 on '@2'", cr_description, channel)) - end - end - }, - on_construct = function(pos) - local meta = minetest.get_meta(pos) - update_meta(meta, true) - meta:set_string("infotext", S("Unconfigured Teleportation Tube")) - end, - on_receive_fields = function(pos,formname,fields,sender) - if not fields.channel -- ignore escaping or clientside manipulation of the form - or (fields.quit and not fields.key_enter_field) - or not pipeworks.may_configure(pos, sender) then - return - end - local new_channel = tostring(fields.channel):trim() - - local meta = minetest.get_meta(pos) - local can_receive = meta:get_int("can_receive") - - -- check for private channels each time before actually changing anything - -- to not even allow switching between can_receive states of private channels - if new_channel ~= "" then - local sender_name = sender:get_player_name() - local name, mode = new_channel:match("^([^:;]+)([:;])") - if name and mode and name ~= sender_name then - --channels starting with '[name]:' can only be used by the named player - if mode == ":" then - minetest.chat_send_player(sender_name, S("Sorry, channel '@1' is reserved for exclusive use by @2", - new_channel, name)) - return - - --channels starting with '[name];' can be used by other players, but cannot be received from - elseif mode == ";" and (fields.cr1 or (can_receive ~= 0 and not fields.cr0)) then - minetest.chat_send_player(sender_name, S("Sorry, receiving from channel '@1' is reserved for @2", - new_channel, name)) - return - end - end - end - - local dirty = false - - -- was the channel changed? - local channel = meta:get_string("channel") - if new_channel ~= channel and (fields.key_enter_field == "channel" or fields.set_channel) then - channel = new_channel - meta:set_string("channel", channel) - dirty = true - end - - -- test if a can_receive button was pressed - if fields.cr0 and can_receive ~= 0 then - can_receive = 0 - update_meta(meta, false) - dirty = true - elseif fields.cr1 and can_receive ~= 1 then - can_receive = 1 - update_meta(meta, true) - dirty = true - end - - -- save if we changed something, handle the empty channel while we're at it - if dirty then - if channel ~= "" then - set_tube(pos, channel, can_receive) - local cr_description = (can_receive == 1) and "sending and receiving" or "sending" - meta:set_string("infotext", S("Teleportation Tube @1 on '@2'", cr_description, channel)) - else - -- remove empty channel tubes, to not have to search through them - remove_tube(pos) - meta:set_string("infotext", S("Unconfigured Teleportation Tube")) - end - end - end, - on_destruct = function(pos) - remove_tube(pos) - end - }, + node_def = def, }) -if minetest.get_modpath("mesecons_mvps") ~= nil then +if minetest.get_modpath("mesecons_mvps") then + -- Update tubes when moved by pistons mesecon.register_on_mvps_move(function(moved_nodes) for _, n in ipairs(moved_nodes) do - if string.find(n.node.name, "pipeworks:teleport_tube") ~= nil then + if n.node.name:find("pipeworks:teleport_tube") then local meta = minetest.get_meta(n.pos) set_tube(n.pos, meta:get_string("channel"), meta:get_int("can_receive")) end @@ -333,11 +325,21 @@ end -- Expose teleport tube database API for other mods pipeworks.tptube = { - hash = hash, + version = tube_db_version, + hash = hash_pos, + get_db = function() return tube_db end, save_tube_db = save_tube_db, - save_tube_db_entry = save_tube_db_entry, - get_db = function() return tp_tube_db or read_tube_db() end, set_tube = set_tube, - update_meta = update_meta, - tp_tube_db_version = tp_tube_db_version + save_tube = save_tube, + update_tube = update_tube, + update_meta = function(meta, cr) + -- Legacy behaviour + if cr ~= nil then + meta:set_int("can_receive", cr and 1 or 0) + end + update_meta(meta) + end, } + +-- Load the database +read_tube_db() From fc0d4990b030fddb38c0842d8f184ee08c20af2e Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Sun, 20 Nov 2022 19:47:14 -0500 Subject: [PATCH 32/40] make minor bugfixes to restore compat with mineclone2 --- mod.conf | 2 +- signal_tubes.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mod.conf b/mod.conf index cab78e8..51e0f95 100644 --- a/mod.conf +++ b/mod.conf @@ -1,5 +1,5 @@ name = pipeworks description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them. depends = basic_materials -optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests +optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core min_minetest_version = 5.4.0 diff --git a/signal_tubes.lua b/signal_tubes.lua index 2713507..3a47e8c 100644 --- a/signal_tubes.lua +++ b/signal_tubes.lua @@ -12,7 +12,7 @@ local function after_break(pos) end if minetest.get_modpath("mesecons") and pipeworks.enable_detector_tube then - local detector_tube_step = 5 * tonumber(minetest.settings:get("dedicated_server_step")) + local detector_tube_step = 5 * (tonumber(minetest.settings:get("dedicated_server_step")) or 0.09) pipeworks.register_tube("pipeworks:detector_tube_on", { description = S("Detecting Pneumatic Tube Segment on"), inventory_image = "pipeworks_detector_tube_inv.png", From 855937aec336db066ab82dfd6008878dda8610f7 Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Fri, 2 Dec 2022 15:54:21 -0500 Subject: [PATCH 33/40] make all nodes diggable in mcl* survival mode --- autocrafter.lua | 3 ++- decorative_tubes.lua | 6 ++++-- devices.lua | 50 ++++++++++++++++++++++++++++--------------- filter-injector.lua | 3 ++- legacy.lua | 3 ++- lua_tube.lua | 6 ++++-- pipes.lua | 8 ++++--- routing_tubes.lua | 3 ++- trashcan.lua | 3 ++- tube_registration.lua | 5 +++-- wielder.lua | 3 ++- 11 files changed, 61 insertions(+), 32 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index ca578e9..22ff6d7 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -272,7 +272,8 @@ minetest.register_node("pipeworks:autocrafter", { description = S("Autocrafter"), drawtype = "normal", tiles = {"pipeworks_autocrafter.png"}, - groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 1}, + groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 1, axey=5}, + _mcl_hardness=1.6, tube = {insert_object = function(pos, node, stack, direction) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() diff --git a/decorative_tubes.lua b/decorative_tubes.lua index 910ea91..37ecec2 100644 --- a/decorative_tubes.lua +++ b/decorative_tubes.lua @@ -14,7 +14,8 @@ minetest.register_node("pipeworks:steel_block_embedded_tube", { }, paramtype = "light", paramtype2 = "facedir", - groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2}, + groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=5}, + _mcl_hardness=1.6, legacy_facedir_simple = true, _sound_def = { key = "node_sound_stone_defaults", @@ -62,7 +63,8 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", { collision_box = pane_box, paramtype = "light", paramtype2 = "facedir", - groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2}, + groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=5}, + _mcl_hardness=1.6, legacy_facedir_simple = true, _sound_def = { key = "node_sound_stone_defaults", diff --git a/devices.lua b/devices.lua index d6bfced..9a08a3c 100644 --- a/devices.lua +++ b/devices.lua @@ -133,9 +133,9 @@ for s in ipairs(states) do local dgroups if states[s] == "off" then - dgroups = {snappy=3, pipe=1, dig_generic = 4} + dgroups = {snappy=3, pipe=1, dig_generic = 4, axey=5} else - dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4} + dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5} end local pumpname = "pipeworks:pump_"..states[s] @@ -148,6 +148,7 @@ for s in ipairs(states) do paramtype = "light", paramtype2 = "facedir", groups = dgroups, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -202,6 +203,7 @@ for s in ipairs(states) do fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } }, groups = dgroups, + _mcl_hardness = 1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -251,7 +253,8 @@ minetest.register_node(nodename_valve_loaded, { type = "fixed", fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } }, - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -303,7 +306,8 @@ minetest.register_node("pipeworks:grating", { }, sunlight_propagates = true, paramtype = "light", - groups = {snappy=3, pipe=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -330,7 +334,8 @@ minetest.register_node(nodename_spigot_empty, { sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -367,7 +372,8 @@ minetest.register_node(nodename_spigot_loaded, { sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -425,7 +431,8 @@ minetest.register_node(nodename_panel_empty, { tiles = { "pipeworks_entry_panel.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -447,7 +454,8 @@ minetest.register_node(nodename_panel_loaded, { tiles = { "pipeworks_entry_panel.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -479,7 +487,8 @@ minetest.register_node(nodename_sensor_empty, { sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -520,7 +529,8 @@ minetest.register_node(nodename_sensor_loaded, { sunlight_propagates = true, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -567,12 +577,12 @@ new_flow_logic_register.transition_simple_set(sensor_pressure_set, { mesecons=pi -- TODO flow-logic-stub: these don't currently do anything under the new flow logic. for fill = 0, 10 do local filldesc=S("empty") - local sgroups = {snappy=3, pipe=1, tankfill=fill+1, dig_generic = 4} + local sgroups = {snappy=3, pipe=1, tankfill=fill+1, dig_generic = 4, axey=5} local image = nil if fill ~= 0 then filldesc=S("@1% full", 10*fill) - sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4} + sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4, axey=5} image = "pipeworks_storage_tank_fittings.png" end @@ -589,7 +599,8 @@ for fill = 0, 10 do inventory_image = image, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -620,6 +631,7 @@ for fill = 0, 10 do paramtype = "light", paramtype2 = "facedir", groups = sgroups, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -648,7 +660,8 @@ minetest.register_node(nodename_fountain_empty, { tiles = { "pipeworks_fountainhead.png" }, sunlight_propagates = true, paramtype = "light", - groups = {snappy=3, pipe=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -685,7 +698,8 @@ minetest.register_node(nodename_fountain_loaded, { tiles = { "pipeworks_fountainhead.png" }, sunlight_propagates = true, paramtype = "light", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -737,7 +751,8 @@ minetest.register_node(nodename_sp_empty, { tiles = { "pipeworks_straight_pipe_empty.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -761,7 +776,8 @@ minetest.register_node(nodename_sp_loaded, { tiles = { "pipeworks_straight_pipe_loaded.png" }, paramtype = "light", paramtype2 = "facedir", - groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}, + groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, diff --git a/filter-injector.lua b/filter-injector.lua index 6e25917..ac98a62 100644 --- a/filter-injector.lua +++ b/filter-injector.lua @@ -388,7 +388,8 @@ for _, data in ipairs({ "pipeworks_"..data.name.."_top.png", }, paramtype2 = "facedir", - groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2}, + groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2, axey=5}, + _mcl_hardness=1.6, legacy_facedir_simple = true, _sound_def = { key = "node_sound_wood_defaults", diff --git a/legacy.lua b/legacy.lua index a426a62..f45c375 100644 --- a/legacy.lua +++ b/legacy.lua @@ -26,7 +26,8 @@ if not minetest.get_modpath("auto_tree_tap") and "pipeworks_nodebreaker_back.png","pipeworks_nodebreaker_front_off.png"}, is_ground_content = true, paramtype2 = "facedir", - groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1 }, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_stone_defaults", }, diff --git a/lua_tube.lua b/lua_tube.lua index 0898749..cae1bf3 100644 --- a/lua_tube.lua +++ b/lua_tube.lua @@ -865,7 +865,7 @@ for white = 0, 1 do tiles[3] = tiles[3]..tiles_on_off.R270:format(white == 1 and "on" or "off"); tiles[4] = tiles[4]..tiles_on_off.R_90:format(white == 1 and "on" or "off"); - local groups = {snappy = 3, tube = 1, tubedevice = 1, overheat = 1, dig_generic = 4} + local groups = {snappy = 3, tube = 1, tubedevice = 1, overheat = 1, dig_generic = 4, axey=5} if red + blue + yellow + green + black + white ~= 0 then groups.not_in_creative_inventory = 1 end @@ -912,6 +912,7 @@ for white = 0, 1 do paramtype = "light", is_ground_content = false, groups = groups, + _mcl_hardness=1.6, drop = BASENAME.."000000", sunlight_propagates = true, selection_box = selection_box, @@ -1023,7 +1024,8 @@ minetest.register_node(BASENAME .. "_burnt", { is_burnt = true, paramtype = "light", is_ground_content = false, - groups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory=1, dig_generic = 4}, + groups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory=1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, drop = BASENAME.."000000", sunlight_propagates = true, selection_box = selection_box, diff --git a/pipes.lua b/pipes.lua index 5ab7c61..1e78417 100644 --- a/pipes.lua +++ b/pipes.lua @@ -37,11 +37,11 @@ for index, connects in ipairs(cconnects) do end --]] - local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4} + local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=5} local pipedesc = S("Pipe Segment").." "..dump(connects) if #connects == 0 then - pgroups = {snappy = 3, tube = 1, dig_generic = 4} + pgroups = {snappy = 3, tube = 1, dig_generic = 4, axey=5} pipedesc = S("Pipe Segment") end @@ -76,6 +76,7 @@ for index, connects in ipairs(cconnects) do fixed = outsel }, groups = pgroups, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_metal_defaults", }, @@ -93,7 +94,7 @@ for index, connects in ipairs(cconnects) do pipenumber = index }) - local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4} + local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=5} minetest.register_node("pipeworks:pipe_"..index.."_loaded", { description = pipedesc, @@ -112,6 +113,7 @@ for index, connects in ipairs(cconnects) do fixed = outsel }, groups = pgroups, + _mcl_hardness = 1.6, _sound_def = { key = "node_sound_metal_defaults", }, diff --git a/routing_tubes.lua b/routing_tubes.lua index 7593322..4ea5c28 100644 --- a/routing_tubes.lua +++ b/routing_tubes.lua @@ -168,7 +168,8 @@ if pipeworks.enable_one_way_tube then 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}, + groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, axey=5}, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_wood_defaults", }, diff --git a/trashcan.lua b/trashcan.lua index 3643828..7c3d4e9 100644 --- a/trashcan.lua +++ b/trashcan.lua @@ -10,7 +10,8 @@ minetest.register_node("pipeworks:trashcan", { "pipeworks_trashcan_side.png", "pipeworks_trashcan_side.png", }, - groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 4}, + groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 4, axey=5}, + _mcl_hardness=1.6, tube = { insert_object = function(pos, node, stack, direction) return ItemStack("") diff --git a/tube_registration.lua b/tube_registration.lua index edb9f5e..0028623 100644 --- a/tube_registration.lua +++ b/tube_registration.lua @@ -61,13 +61,13 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e outimgs[vti[v]] = ends[v] end - local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1, dig_generic = 4} + local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=5} 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} + tgroups = {snappy = 3, tube = 1, tubedevice = 1, dig_generic = 4, axey=5} tubedesc = desc iimg=inv outimgs = { @@ -106,6 +106,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e fixed = outboxes }, groups = tgroups, + _mcl_hardness=1.6, _sound_def = { key = "node_sound_wood_defaults", }, diff --git a/wielder.lua b/wielder.lua index 6bde2df..e24b8ce 100644 --- a/wielder.lua +++ b/wielder.lua @@ -146,7 +146,7 @@ local function register_wielder(data) data.fixup_node = data.fixup_node or function (pos, node) end data.fixup_oldmetadata = data.fixup_oldmetadata or function (m) return m end for _, state in ipairs({ "off", "on" }) do - local groups = { snappy=2, choppy=2, oddly_breakable_by_hand=2, mesecon=2, tubedevice=1, tubedevice_receiver=1 } + local groups = { snappy=2, choppy=2, oddly_breakable_by_hand=2, mesecon=2, tubedevice=1, tubedevice_receiver=1, axey=5 } if state == "on" then groups.not_in_creative_inventory = 1 end local tile_images = {} for _, face in ipairs({ "top", "bottom", "side2", "side1", "back", "front" }) do @@ -199,6 +199,7 @@ local function register_wielder(data) paramtype2 = "facedir", tubelike = 1, groups = groups, + _mcl_hardness=0.6, _sound_def = { key = "node_sound_stone_defaults", }, From b0b675f715d952e7505291b6647484c6dbb573c7 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Sun, 8 Jan 2023 21:51:49 -0500 Subject: [PATCH 34/40] Fix deprecated call to `player:get_look_pitch()` Fixes #53 --- devices.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devices.lua b/devices.lua index 9a08a3c..c5c9bf1 100644 --- a/devices.lua +++ b/devices.lua @@ -35,7 +35,7 @@ function pipeworks.rotate_on_place(itemstack, placer, pointed_thing) else - local pitch = placer:get_look_pitch() + local pitch = -placer:get_look_vertical() local above = pointed_thing.above local under = pointed_thing.under local fdir = minetest.dir_to_facedir(placer:get_look_dir()) From bd5a42356bc20a71dac5d11ea04deb4fa6246d0e Mon Sep 17 00:00:00 2001 From: Awkanimus <119243140+Awkanimus@users.noreply.github.com> Date: Thu, 26 Jan 2023 15:44:41 -0500 Subject: [PATCH 35/40] Use sane default i3 inventory settings when missing (#57) - i3.settings.hotbar_len and i3.settings.inv_size were removed in commit 75fddf7 because they are now per-player settings - This just uses sane defaults when the settings are not present to avoid a few nils and allow the game to continue --- common.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common.lua b/common.lua index 4746906..1161ba6 100644 --- a/common.lua +++ b/common.lua @@ -149,7 +149,8 @@ function fs_helpers.get_inv(y) local inv_x = i3.settings.legacy_inventory and 0.75 or 0.22 local inv_y = (y + 0.4) or 6.9 local size, spacing = 1, 0.1 - local hotbar_len = i3.settings.hotbar_len + local hotbar_len = i3.settings.hotbar_len or (i3.settings.legacy_inventory and 8 or 9) + local inv_size = i3.settings.inv_size or (hotbar_len * 4) table.insert(fs, "style_type[box;colors=#77777710,#77777710,#777,#777]") @@ -162,13 +163,13 @@ function fs_helpers.get_inv(y) table.insert(fs, "style_type[box;colors=#666]") for i=0, 2 do - for j=0, (i3.settings.legacy_inventory and 7 or 8) do + for j=0, hotbar_len - 1 do table.insert(fs, "box["..0.2+(j*0.1)+(j*size)..","..(inv_y+size+spacing+0.05)+(i*0.1)+(i*size)..";"..size..","..size..";]") end end table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") - table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(i3.settings.inv_size / hotbar_len)..";"..hotbar_len.."]") + table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(inv_size / hotbar_len)..";"..hotbar_len.."]") else table.insert(fs, "list[current_player;main;0.22,"..y..";8,4;]") end From 56bcc7dbb7bd269b5de9d8359dce4ca7b8d30521 Mon Sep 17 00:00:00 2001 From: fluxionary <25628292+fluxionary@users.noreply.github.com> Date: Thu, 18 May 2023 10:49:12 -0700 Subject: [PATCH 36/40] log when items teleport through tubes (#66) * log when items teleport through tubes * put teleport tube logging bethind a setting * narrow scope of some variables --- settingtypes.txt | 3 +++ teleport_tube.lua | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/settingtypes.txt b/settingtypes.txt index ba25914..6d8e3ad 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -84,3 +84,6 @@ pipeworks_use_real_entities (Use Real Entities) bool true #A high value may cause issues with tube entity visuals. #A value 0.2 or above may cause issues with accelerator tubes. pipeworks_entity_update_interval (Entity Update Interval) float 0 0 0.8 + +# if set to true, items passing through teleport tubes will log log where they came from and where they went. +pipeworks_log_teleport_tubes (Log Teleport Tubes) bool false diff --git a/teleport_tube.lua b/teleport_tube.lua index 74a610a..4b6b2ed 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -233,7 +233,8 @@ local function can_go(pos, node, velocity, stack) velocity.x = 0 velocity.y = 0 velocity.z = 0 - local channel = minetest.get_meta(pos):get_string("channel") + local src_meta = minetest.get_meta(pos) + local channel = src_meta:get_string("channel") if channel == "" then return {} end @@ -242,6 +243,14 @@ local function can_go(pos, node, velocity, stack) return {} end local target = receivers[math.random(1, #receivers)] + if minetest.settings:get_bool("pipeworks_log_teleport_tubes", false) then + local src_owner = src_meta:get_string("owner") + local dst_meta = minetest.get_meta(pos) + local dst_owner = dst_meta:get_string("owner") + minetest.log("action", string.format("[pipeworks] %s teleported from %s (owner=%s) to %s (owner=%s) via %s", + stack:to_string(), minetest.pos_to_string(pos), src_owner, minetest.pos_to_string(target), dst_owner, channel + )) + end pos.x = target.x pos.y = target.y pos.z = target.z From 2c880a3843147dadd71aba3955054ae65be9e912 Mon Sep 17 00:00:00 2001 From: OgelGames Date: Fri, 19 May 2023 14:17:04 +1000 Subject: [PATCH 37/40] cache teleport tube logging setting this gets checked every time an item is teleported --- teleport_tube.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/teleport_tube.lua b/teleport_tube.lua index 4b6b2ed..2a87610 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -3,6 +3,8 @@ local S = minetest.get_translator("pipeworks") local filename = minetest.get_worldpath().."/teleport_tubes" -- Only used for backward-compat local storage = minetest.get_mod_storage() +local enable_logging = minetest.settings:get_bool("pipeworks_log_teleport_tubes", false) + local has_digilines = minetest.get_modpath("digilines") -- V1: Serialized text file indexed by vector position. @@ -243,7 +245,7 @@ local function can_go(pos, node, velocity, stack) return {} end local target = receivers[math.random(1, #receivers)] - if minetest.settings:get_bool("pipeworks_log_teleport_tubes", false) then + if enable_logging then local src_owner = src_meta:get_string("owner") local dst_meta = minetest.get_meta(pos) local dst_owner = dst_meta:get_string("owner") From 9395013cde0c05677b841ac4db5e1b45b71147b1 Mon Sep 17 00:00:00 2001 From: Luke aka SwissalpS Date: Sun, 28 May 2023 04:49:25 +0200 Subject: [PATCH 38/40] Support setting teleport tube `can_receive` by digilines (#68) * allow setting can_receive flag by digilines basically also allows sending tables to change both or either the tp-channel and receive toggle * apply suggestions Co-authored-by: OgelGames --------- Co-authored-by: OgelGames --- teleport_tube.lua | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/teleport_tube.lua b/teleport_tube.lua index 2a87610..e888333 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -270,14 +270,29 @@ local function repair_tube(pos, node) update_meta(meta) end -local function digiline_action(pos, _, channel, msg) +local function digiline_action(pos, _, digiline_channel, msg) local meta = minetest.get_meta(pos) - if channel ~= meta:get_string("digiline_channel") or type(msg) ~= "string" then + if digiline_channel ~= meta:get_string("digiline_channel") then return end - local name = meta:get_string("owner") - local cr = meta:get_int("can_receive") - update_tube(pos, msg, cr, name) + local channel = meta:get_string("channel") + local can_receive = meta:get_int("can_receive") + if type(msg) == "string" then + channel = msg + elseif type(msg) == "table" then + if type(msg.channel) == "string" then + channel = msg.channel + end + if msg.can_receive == 1 or msg.can_receive == true then + can_receive = 1 + elseif msg.can_receive == 0 or msg.can_receive == false then + can_receive = 0 + end + else + return + end + local player_name = meta:get_string("owner") + update_tube(pos, channel, can_receive, player_name) update_meta(meta) end From caa33e6375ded75755dee9a1b885531904273032 Mon Sep 17 00:00:00 2001 From: OgelGames Date: Tue, 13 Jun 2023 16:27:23 +1000 Subject: [PATCH 39/40] fix autocrafter replacements --- autocrafter.lua | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 22ff6d7..aeb2507 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -35,16 +35,38 @@ end local function autocraft(inventory, craft) if not craft then return false end - local output_item = craft.output.item + local output = craft.output.item -- check if we have enough room in dst - if not inventory:room_for_item("dst", output_item) then return false end + if not inventory:room_for_item("dst", output) then return false end local consumption = craft.consumption local inv_index = count_index(inventory:get_list("src")) -- check if we have enough material available for itemname, number in pairs(consumption) do if (not inv_index[itemname]) or inv_index[itemname] < number then return false end end + -- check if output and all replacements fit in dst + local out_items = count_index(craft.decremented_input.items) + out_items[output:get_name()] = (out_items[output:get_name()] or 0) + output:get_count() + local empty_count = 0 + for _,item in pairs(inventory:get_list("dst")) do + if item:is_empty() then + empty_count = empty_count + 1 + else + local name = item:get_name() + if out_items[name] then + out_items[name] = out_items[name] - item:get_free_space() + end + end + end + for _,count in pairs(out_items) do + if count > 0 then + empty_count = empty_count - 1 + end + end + if empty_count < 0 then + return false + end -- consume material for itemname, number in pairs(consumption) do for _ = 1, number do -- We have to do that since remove_item does not work if count > stack_max @@ -53,7 +75,7 @@ local function autocraft(inventory, craft) end -- craft the result into the dst inventory and add any "replacements" as well - inventory:add_item("dst", output_item) + inventory:add_item("dst", output) for i = 1, 9 do inventory:add_item("dst", craft.decremented_input.items[i]) end From d8a364e73167b1eb858ce6927a6da94b54935ad8 Mon Sep 17 00:00:00 2001 From: OgelGames Date: Tue, 13 Jun 2023 22:07:53 +1000 Subject: [PATCH 40/40] remove unnecessary check and move some code --- autocrafter.lua | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index aeb2507..00869e1 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -35,17 +35,13 @@ end local function autocraft(inventory, craft) if not craft then return false end - local output = craft.output.item - - -- check if we have enough room in dst - if not inventory:room_for_item("dst", output) then return false end - local consumption = craft.consumption - local inv_index = count_index(inventory:get_list("src")) -- check if we have enough material available - for itemname, number in pairs(consumption) do + local inv_index = count_index(inventory:get_list("src")) + for itemname, number in pairs(craft.consumption) do if (not inv_index[itemname]) or inv_index[itemname] < number then return false end end -- check if output and all replacements fit in dst + local output = craft.output.item local out_items = count_index(craft.decremented_input.items) out_items[output:get_name()] = (out_items[output:get_name()] or 0) + output:get_count() local empty_count = 0 @@ -68,12 +64,11 @@ local function autocraft(inventory, craft) return false end -- consume material - for itemname, number in pairs(consumption) do + for itemname, number in pairs(craft.consumption) do for _ = 1, number do -- We have to do that since remove_item does not work if count > stack_max inventory:remove_item("src", ItemStack(itemname)) end end - -- craft the result into the dst inventory and add any "replacements" as well inventory:add_item("dst", output) for i = 1, 9 do