From 1701671e9c36ca2926a9934e21a1905ce3f84dc7 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:14:14 -0500 Subject: [PATCH 01/54] trashcan voids water --- trashcan.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/trashcan.lua b/trashcan.lua index c8ae9b2e..81c4c6d6 100644 --- a/trashcan.lua +++ b/trashcan.lua @@ -1,5 +1,6 @@ local S = minetest.get_translator("pipeworks") -minetest.register_node("pipeworks:trashcan", { +local voidname = "pipeworks:trashcan" +minetest.register_node(voidname, { description = S("Trash Can"), drawtype = "normal", tiles = { @@ -20,6 +21,7 @@ minetest.register_node("pipeworks:trashcan", { connect_sides = {left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1}, priority = 1, -- Lower than anything else }, + pipe_connections = { top = 1, bottom = 1, front = 1, back = 1, left = 1, right = 1}, on_construct = function(pos) local meta = minetest.get_meta(pos) local size = "10.2,9" @@ -49,4 +51,6 @@ minetest.register_node("pipeworks:trashcan", { minetest.get_meta(pos):get_inventory():set_stack(listname, index, ItemStack("")) end, }) -pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:trashcan" +pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = voidname +pipeworks.flowables.register.simple(voidname) +pipeworks.flowables.register.output(voidname, 0, 0, function() return 4 end, function()end) From 5ba89d0e7f00b7ac234150e9d86c12f21bf6bdce Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:51:40 -0500 Subject: [PATCH 02/54] trashcan updates pipes --- trashcan.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/trashcan.lua b/trashcan.lua index 81c4c6d6..f014208d 100644 --- a/trashcan.lua +++ b/trashcan.lua @@ -50,6 +50,12 @@ minetest.register_node(voidname, { on_metadata_inventory_put = function(pos, listname, index, stack, player) minetest.get_meta(pos):get_inventory():set_stack(listname, index, ItemStack("")) end, + after_place_node = function(pos) + pipeworks.scan_for_pipe_objects(pos) + end, + after_dig_node = function(pos) + pipeworks.scan_for_pipe_objects(pos) + end, }) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = voidname pipeworks.flowables.register.simple(voidname) From 392677f4251cf8657753b5f20dabec22ad52c5dc Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:53:12 -0500 Subject: [PATCH 03/54] trash can needs pipe logic now --- init.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/init.lua b/init.lua index 6d85a066..b8957342 100644 --- a/init.lua +++ b/init.lua @@ -51,6 +51,17 @@ if minetest.get_modpath("signs_lib") then dofile(pipeworks.modpath.."/signs_compat.lua") end +local logicdir = "/pressure_logic/" + +-- note that even with these files the new flow logic is not yet default. +-- registration will take place but no actual ABMs/node logic will be installed, +-- unless the toggle flag is specifically enabled in the per-world settings flag. +-- -- disregard previous comments, new flow logic is default now +dofile(pipeworks.modpath..logicdir.."flowable_node_registry.lua") +dofile(pipeworks.modpath..logicdir.."abms.lua") +dofile(pipeworks.modpath..logicdir.."abm_register.lua") +dofile(pipeworks.modpath..logicdir.."flowable_node_registry_install.lua") + dofile(pipeworks.modpath.."/common.lua") dofile(pipeworks.modpath.."/models.lua") dofile(pipeworks.modpath.."/autoplace_pipes.lua") @@ -80,16 +91,6 @@ if pipeworks.enable_sand_tube or pipeworks.enable_mese_sand_tube then dofile(pipeworks.modpath.."/tubes/vacuum.lua") end -local logicdir = "/pressure_logic/" - --- note that even with these files the new flow logic is not yet default. --- registration will take place but no actual ABMs/node logic will be installed, --- unless the toggle flag is specifically enabled in the per-world settings flag. -dofile(pipeworks.modpath..logicdir.."flowable_node_registry.lua") -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 From 52aca25ce1929aefc09a8144f79cf0fb4d7838af Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:06:34 -0500 Subject: [PATCH 04/54] offsets --- common.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/common.lua b/common.lua index f12e530a..4d4ac6f6 100644 --- a/common.lua +++ b/common.lua @@ -211,19 +211,21 @@ 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) +function fs_helpers.get_inv(y,x) + local x = x or 0 local fs = {} if minetest.get_modpath("i3") then - local inv_x = i3.settings.legacy_inventory and 0.75 or 0.22 + local inv_x = (i3.settings.legacy_inventory and 0.75 or 0.22) + x local inv_y = (y + 0.4) or 6.9 local size, spacing = 1, 0.1 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) + local hotbar_width = 4 + local inv_size = i3.settings.inv_size or (hotbar_len * hotbar_width) 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..";]") + table.insert(fs, "box["..(inv_x + (i * (spacing + size)))..","..inv_y..";"..size..","..size..";]") end table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") @@ -232,14 +234,14 @@ function fs_helpers.get_inv(y) table.insert(fs, "style_type[box;colors=#666]") for i=0, 2 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..";]") + table.insert(fs, "box["..0.2+(j*(spacing+size))..","..(inv_y+size+spacing+0.05)+(i*(spacing+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..","..(inv_size / hotbar_len)..";"..hotbar_len.."]") + table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..hotbar_width..";"..hotbar_len.."]") elseif minetest.get_modpath("mcl_formspec") then - local inv_x = 0.22 + local inv_x = 0.22 + x local inv_y = (y + 0.4) or 6.9 local size, spacing = 1, 0.1 local hotbar_len = 9 @@ -248,7 +250,7 @@ function fs_helpers.get_inv(y) 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..";]") + table.insert(fs, "box["..(inv_x + (i * (spacing + size)))..","..inv_y..";"..size..","..size..";]") end table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") @@ -257,14 +259,14 @@ function fs_helpers.get_inv(y) table.insert(fs, "style_type[box;colors=#666]") for i=0, 2 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..";]") + table.insert(fs, "box["..0.2+(j*(spacing+size))..","..(inv_y+size+spacing+0.05)+(i*(spacing+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..","..(inv_size / hotbar_len)..";"..hotbar_len.."]") else - table.insert(fs, "list[current_player;main;0.22,"..y..";8,4;]") + table.insert(fs, "list[current_player;main;".. (0.22 + x) ..","..y..";8,4;]") end return table.concat(fs, "") From 5a543ce7c5dac5fe011ce1053f24878f12062df5 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:08:07 -0500 Subject: [PATCH 05/54] pressure default --- default_settings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default_settings.lua b/default_settings.lua index 3ea96852..81644497 100644 --- a/default_settings.lua +++ b/default_settings.lua @@ -48,7 +48,7 @@ pipeworks.toggles = {} -- setting to nil inhibits all flow logic, useful for debugging ABM crashes, -- or for rendering the pipes purely decorative. ]] -pipeworks.toggles.pipe_mode = "classic" +pipeworks.toggles.pipe_mode = "pressure" --[[ -- force-enable finite water handling mode. -- this changes the way that water node placement is handled; From 54c40b6c65b75515fe70b2ebb5faf45ffd0c4dcf Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:58:49 -0500 Subject: [PATCH 06/54] creative water source --- devices.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/devices.lua b/devices.lua index 9d0a2a1e..afd1c7f8 100644 --- a/devices.lua +++ b/devices.lua @@ -127,6 +127,32 @@ local pipes_devicelist = { -- Now define the nodes. +local sourcename = "pipeworks:source_loaded" +local tile = table.copy(core.registered_nodes[pipeworks.liquids.water.source].tiles[1]) +tile.name = tile.name .. "^pipeworks_source_frame.png" +core.register_node(sourcename, { + description = S("Infinite Water Source"), + tiles = { tile }, + paramtype = "light", + groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, + is_ground_content = false, + _mcl_hardness=0.8, + _sound_def = { + key = "node_sound_metal_defaults", + }, + walkable = true, + pipe_connections = { top = 1, bottom = 1, front = 1, back = 1, left = 1, right = 1}, + after_place_node = function(pos) + pipeworks.scan_for_pipe_objects(pos) + end, + after_dig_node = function(pos) + pipeworks.scan_for_pipe_objects(pos) + end +}) + +new_flow_logic_register.simple(sourcename) +new_flow_logic_register.intake(sourcename, 4, function() return 4 end) + local states = { "on", "off" } for s in ipairs(states) do From f7dbcbebb4193112259f0bcff3209e00342e38d0 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Fri, 25 Apr 2025 17:01:33 -0500 Subject: [PATCH 07/54] fluid crafts --- crafts.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/crafts.lua b/crafts.lua index 45f642cf..d35e4c9e 100644 --- a/crafts.lua +++ b/crafts.lua @@ -316,3 +316,33 @@ if pipeworks.enable_node_breaker then } }) end + +if pipeworks.enable_autocrafter then + +local buckets = {} +if core.get_modpath("bucket") then + buckets.air = "bucket:bucket_empty" + buckets.water = "bucket:bucket_water" + buckets.river_water = "bucket:bucket_river_water" + buckets.lava = "bucket:bucket_lava" +elseif core.get_modpath("mcl_buckets") then + buckets.air = "mcl_buckets:bucket_empty" + buckets.water = "mcl_buckets:bucket_water" + buckets.river_water = "mcl_buckets:bucket_river_water" + buckets.lava = "mcl_buckets:bucket_lava" +end + +if buckets.air and buckets.water then +local fluid = {type = "water", amount = 1} +local recipe = { + output = buckets.water, + recipe = { + {buckets.air}, + {""}, + {""} + } +} +pipeworks.register_fluid_recipe(recipe, fluid) +end + +end From 2e2a63a3168627a1ee764704975b4b784512260c Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Fri, 25 Apr 2025 17:10:04 -0500 Subject: [PATCH 08/54] autocrafter with fluids --- autocrafter.lua | 250 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 167 insertions(+), 83 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index b4954b6f..024bd13b 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -6,6 +6,90 @@ local autocrafterCache = {} local craft_time = 1 local next = next +local function get_item_info(stack) + local name = stack:get_name() + local def = minetest.registered_items[name] + local description = def and def.description or S("Unknown item") + return description, name +end + +-- returns false if we shouldn't bother attempting to start the timer again +-- after this +local function update_meta(meta, enabled) + local state = enabled and "on" or "off" + meta:set_int("enabled", enabled and 1 or 0) + local list_backgrounds = "" + if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then + list_backgrounds = "style_type[box;colors=#666]" + for i = 0, 2 do + for j = 0, 2 do + list_backgrounds = list_backgrounds .. "box[" .. + 1.5 + (i * 1.25) .. "," .. 0.25 + (j * 1.25) .. ";1,1;]" + end + end + for i = 0, 3 do + for j = 0, 2 do + list_backgrounds = list_backgrounds .. "box[" .. + 5.28 + 1.25 + (i * 1.25) .. "," .. 0.25 + (j * 1.25) .. ";1,1;]" + end + end + for i = 0, 7 do + for j = 0, 2 do + list_backgrounds = list_backgrounds .. "box[" .. + 1.5 + (i * 1.25) .. "," .. 5 + (j * 1.25) .. ";1,1;]" + end + end + end + local size = "11.5,14" + local fluid = meta:get("fluidtype") + local amount = meta:get_float("fluidamount") + local fluid_cap = meta:get_float("fluidcap") + local bar_height = 8.25 * amount / fluid_cap + local fs = + "formspec_version[4]" .. + "size[" .. size .. "]" .. + pipeworks.fs_helpers.get_prepends(size) .. + list_backgrounds .. + "list[context;recipe;1.47,0.22;3,3;]" .. + "image[5.25,1.45;1,1;[combine:16x16^[noalpha^[colorize:#141318:255]" .. + "list[context;output;5.25,1.45;1,1;]" .. + "image_button[5.25,2.6;1,0.6;pipeworks_button_" .. state .. ".png;" .. + state .. ";;;false;pipeworks_button_interm.png]" .. + "list[context;dst;6.53,0.22;4,3;]" .. + "list[context;src;1.47,5;8,3;]" ..-- + pipeworks.fs_helpers.get_inv(9,1.25) .. + "listring[current_player;main]" .. + "listring[context;src]" .. + "listring[current_player;main]" .. + "listring[context;dst]" .. + "listring[current_player;main]" .. + "image[0.22," .. (8.5 - bar_height) .. ";1," .. bar_height .. ";pipeworks_fluid_" .. (fluid or "air") .. ".png]" .. + "image[0.22,0.25;1,8.25;pipeworks_fluidbar.png]" + if minetest.get_modpath("digilines") then + fs = fs .. "field[1.47,4;4.5,0.75;channel;" .. S("Channel") .. + ";${channel}]" .. + "button[6.25,4;1.5,0.75;set_channel;" .. S("Set") .. "]" .. + "button_exit[8.05,4;2,0.75;close;" .. S("Close") .. "]" + end + meta:set_string("formspec", fs) + + -- toggling the button doesn't quite call for running a recipe change check + -- so instead we run a minimal version for infotext setting only + -- this might be more written code, but actually executes less + local output = meta:get_inventory():get_stack("output", 1) + if output:is_empty() then -- doesn't matter if paused or not + meta:set_string("infotext", S("unconfigured Autocrafter")) + return false + end + + local description, name = get_item_info(output) + local infotext = enabled and S("'@1' Autocrafter (@2)", description, name) + or S("paused '@1' Autocrafter", description) + + meta:set_string("infotext", infotext) + return enabled +end + local function count_index(invlist) local index = {} for _, stack in pairs(invlist) do @@ -18,13 +102,6 @@ local function count_index(invlist) return index end -local function get_item_info(stack) - local name = stack:get_name() - local def = minetest.registered_items[name] - local description = def and def.description or S("Unknown item") - return description, name -end - -- Get best matching recipe for what user has put in crafting grid. -- This function does not consider crafting method (mix vs craft) local function get_matching_craft(output_name, example_recipe) @@ -76,13 +153,22 @@ local function get_craft(pos, inventory, hash) local output, decremented_input = minetest.get_craft_result({ method = "normal", width = 3, items = example_recipe }) + + if (not output) or (output.item:is_empty()) then + example_recipe[#example_recipe + 1] = ItemStack("air 65535") + output, decremented_input = core.get_craft_result({ + method = "normal", width = 3, items = example_recipe -- GOHERE + }) + end + pipeworks.fluid_recipes.take_fluid(decremented_input.items) local recipe = example_recipe if output and not output.item:is_empty() then recipe = get_matching_craft(output.item:get_name(), example_recipe) end craft = { + fluid = pipeworks.fluid_recipes.take_fluid(recipe), recipe = recipe, consumption = count_index(recipe), output = output, @@ -207,12 +293,21 @@ local function has_room_for_output(list_output, index_output) return true end -local function autocraft(inventory, craft) +-- returns true if not enough fluid +local function check_fluid_insufficiency(req, input) + if not req then return false end + if not input then return true end + if input.type ~= req.type then return true end + if input.amount < req.amount then return true end +end + +local function autocraft(inventory, craft, fluid) if not craft then return false end -- check if output and all replacements fit in dst local output = craft.output.item local out_items = count_index(craft.decremented_input) + local craftfluid = craft.fluid out_items[output:get_name()] = (out_items[output:get_name()] or 0) + output:get_count() @@ -223,7 +318,7 @@ local function autocraft(inventory, craft) -- check if we have enough material available local inv_index = count_index(inventory:get_list("src")) local consumption = calculate_consumption(inv_index, craft.consumption) - if not consumption then + if craftfluid and ((not consumption) or check_fluid_insufficiency(craftfluid, fluid)) then return false end @@ -234,6 +329,7 @@ local function autocraft(inventory, craft) inventory:remove_item("src", ItemStack(itemname)) end end + if craftfluid then fluid.amount = fluid.amount - craftfluid.amount end -- craft the result into the dst inventory and add any "replacements" as well inventory:add_item("dst", output) @@ -262,9 +358,12 @@ local function run_autocrafter(pos, elapsed) return false end + local fluid = {type = meta:get("fluidtype"), amount = meta:get_float("fluidamount")} for _ = 1, math.floor(elapsed / craft_time) do - local continue = autocraft(inventory, craft) + local continue = autocraft(inventory, craft, fluid) if not continue then return false end + meta:set_float("fluidamount", fluid.amount) + update_meta(meta, meta:get_int("enabled") == 1) end return true end @@ -343,77 +442,6 @@ local function on_output_change(pos, inventory, stack) after_recipe_change(pos, inventory) end --- returns false if we shouldn't bother attempting to start the timer again --- after this -local function update_meta(meta, enabled) - local state = enabled and "on" or "off" - meta:set_int("enabled", enabled and 1 or 0) - local list_backgrounds = "" - if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") 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) .. "," .. 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,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.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) - - -- toggling the button doesn't quite call for running a recipe change check - -- so instead we run a minimal version for infotext setting only - -- this might be more written code, but actually executes less - local output = meta:get_inventory():get_stack("output", 1) - if output:is_empty() then -- doesn't matter if paused or not - meta:set_string("infotext", S("unconfigured Autocrafter")) - return false - end - - local description, name = get_item_info(output) - local infotext = enabled and S("'@1' Autocrafter (@2)", description, name) - or S("paused '@1' Autocrafter", description) - - meta:set_string("infotext", infotext) - return enabled -end - -- 1st version of the autocrafter had actual items in the crafting grid -- the 2nd replaced these with virtual items, dropped the content on update and -- set "virtual_items" to string "1" @@ -453,6 +481,41 @@ local function upgrade_autocrafter(pos, meta) end end +pipeworks.fluid_recipes = {} + +pipeworks.fluid_recipes.take_fluid = function(recipe) + local stack = recipe[#recipe][1] + if stack == nil then stack = recipe[#recipe] end + if type(stack) == "userdata" then + if stack:get_name() ~= "air" then return end + stack = stack:get_count() + else + stack = string.split(stack, " ") + if stack[1] ~= "air" then return end + stack = stack[2] + end + local fluid = pipeworks.fluid_recipes[tonumber(stack)] + recipe[#recipe] = nil + return fluid +end + +local modify_recipe = function(recipe, fluid) + local modified_recipe = table.copy(recipe) + if type(fluid) == "number" then + -- do not use this unless you know what you are doing + modified_recipe.recipe[#modified_recipe.recipe + 1] = {"air " .. fluid} + else + pipeworks.fluid_recipes[#pipeworks.fluid_recipes + 1] = fluid + modified_recipe.recipe[#modified_recipe.recipe + 1] = {"air " .. #pipeworks.fluid_recipes} + end + modified_recipe.type = "shaped" + return modified_recipe +end + +pipeworks.register_fluid_recipe = function(recipe, fluid) + core.register_craft(modify_recipe(recipe, fluid)) +end + minetest.register_node("pipeworks:autocrafter", { description = S("Autocrafter"), drawtype = "normal", @@ -460,6 +523,7 @@ minetest.register_node("pipeworks:autocrafter", { groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 1, axey=1, handy=1, pickaxey=1}, is_ground_content = false, _mcl_hardness=0.8, + pipe_connections = { top = 1, bottom = 1, left = 1, right = 1, front = 1, back = 1 }, tube = {insert_object = function(pos, node, stack, direction) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -479,6 +543,8 @@ minetest.register_node("pipeworks:autocrafter", { }, on_construct = function(pos) local meta = minetest.get_meta(pos) + meta:set_float("fluidcap", 8) + meta:set_string("fluidtype", "water") local inv = meta:get_inventory() inv:set_size("src", 3 * 8) inv:set_size("recipe", 3 * 3) @@ -511,9 +577,13 @@ minetest.register_node("pipeworks:autocrafter", { local inv = meta:get_inventory() return (inv:is_empty("src") and inv:is_empty("dst")) end, - after_place_node = pipeworks.scan_for_tube_objects, + after_place_node = function(pos) + pipeworks.scan_for_tube_objects(pos) + pipeworks.scan_for_pipe_objects(pos) + end, after_dig_node = function(pos) pipeworks.scan_for_tube_objects(pos) + pipeworks.scan_for_pipe_objects(pos) end, on_destruct = function(pos) autocrafterCache[minetest.hash_node_position(pos)] = nil @@ -646,4 +716,18 @@ minetest.register_node("pipeworks:autocrafter", { }, }, }) -pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list + 1] = "pipeworks:autocrafter" + +-- autocrafter fluid stuff +local autocraftername = "pipeworks:autocrafter" +pipeworks.flowables.register.simple(autocraftername) +pipeworks.flowables.register.output(autocraftername, 0, 0, function(pos, node, currentpressure, finitemode) + local meta = core.get_meta(pos) + local fluid_cap = meta:get_float("fluidcap") + local fluid_amount = meta:get_float("fluidamount") + local taken = math.min(fluid_cap - fluid_amount, currentpressure) + meta:set_float("fluidamount", fluid_amount + taken) + update_meta(meta, meta:get_int("enabled") == 1) + return taken +end, function()end) + +pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list + 1] = autocraftername From 0fab0c282fdfb53bf8770d5e999a14cf1f743bb6 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Fri, 25 Apr 2025 17:20:17 -0500 Subject: [PATCH 09/54] Add files via upload --- textures/pipeworks_fluid_water.png | Bin 0 -> 83 bytes textures/pipeworks_fluidbar.png | Bin 0 -> 1029 bytes textures/pipeworks_source_frame.png | Bin 0 -> 633 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 textures/pipeworks_fluid_water.png create mode 100644 textures/pipeworks_fluidbar.png create mode 100644 textures/pipeworks_source_frame.png diff --git a/textures/pipeworks_fluid_water.png b/textures/pipeworks_fluid_water.png new file mode 100644 index 0000000000000000000000000000000000000000..82847a2cbb0cf12baba9cf1854e0d95d8b173ec3 GIT binary patch literal 83 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k92}K#X;^)4C~IxyaaN1JzX3_IA$ha dIC``{TxPrcPd<+&sFqyrozqn9Gm{`R=B&L^V8qW3ohDoTK(O-;Oc$O zs=r$o+>Gbk^;f^ngPcJHN^0zw3mT=UG?&3z_ixJj=;{E)(9~XMOq4 zcf$MmtiAs{FT8xuy7r&nh1cs@&;Ike@V5S=G84JBdNi*)_`|X8ZoRO|Fa0K;dOeS? z%bQ~A)jYnbH|6}-^Z1_MRP$daO!-ypxXNDi$uDEaP4wkvk|?k_-~k{=fOh)MvkcLC=zn0U+(3u6{1-oD!M< Dw-y_T literal 0 HcmV?d00001 diff --git a/textures/pipeworks_source_frame.png b/textures/pipeworks_source_frame.png new file mode 100644 index 0000000000000000000000000000000000000000..8e8e8612740805e2786b56ed14d1d2a9281138c5 GIT binary patch literal 633 zcmeAS@N?(olHy`uVBq!ia0vp^0t^g{3><7g)~=v$en5(`ILO_JVcj{ImkbO{#-1*Y zAr*7pUUBq$Y#`D0(7f}pm0$=*=jyL)9x)BFkN65$@(u|KtkF_DGHsR4giBl2O|BO^ zakb>snH9g!YpeUcdB1(~@*R8knm(6NWVy9X^}91i#ryK_x3(Rv_UCBawT@FUV4CW> zRa$L{37c;+2sj-$BXL~Nc(IQ6p6?>Aj$WN_%TAYAEq!0@=kH&bdwbK(oEhnc z%qb`=+_?JZcTR>=%Q7=&rR9J4^l6huSJURr#^=tTf4S>jg7EKs>3icIzuKj?v?Soz z)vH(S?bk>={=WRr_T)eDuYb!K|MoNJdwfxN$rKOGz&-o+-LmK_iFNOpD53oNYt{Al zzvoFPufCe~-fC$}G2in!$r5a8lQ}~}4f~XTW}M|QzWulJUNyt2Rkw75PB2$0@IPs^ znZSOcd5(h|m|MgI5j(*NmiVNgK7sucP>#9^KI}cAFI*-QJcseA0Wd8wc)I$ztaD0e F0syk4B&PrX literal 0 HcmV?d00001 From 8d5d92d0a87915357f8706137067e889af8f589e Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 03:37:15 -0500 Subject: [PATCH 10/54] fluid crafts without core --- autocrafter.lua | 145 ++++++++++++++++++++++++++++-------------------- 1 file changed, 84 insertions(+), 61 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 024bd13b..c3d372e8 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -45,32 +45,6 @@ local function update_meta(meta, enabled) local amount = meta:get_float("fluidamount") local fluid_cap = meta:get_float("fluidcap") local bar_height = 8.25 * amount / fluid_cap - local fs = - "formspec_version[4]" .. - "size[" .. size .. "]" .. - pipeworks.fs_helpers.get_prepends(size) .. - list_backgrounds .. - "list[context;recipe;1.47,0.22;3,3;]" .. - "image[5.25,1.45;1,1;[combine:16x16^[noalpha^[colorize:#141318:255]" .. - "list[context;output;5.25,1.45;1,1;]" .. - "image_button[5.25,2.6;1,0.6;pipeworks_button_" .. state .. ".png;" .. - state .. ";;;false;pipeworks_button_interm.png]" .. - "list[context;dst;6.53,0.22;4,3;]" .. - "list[context;src;1.47,5;8,3;]" ..-- - pipeworks.fs_helpers.get_inv(9,1.25) .. - "listring[current_player;main]" .. - "listring[context;src]" .. - "listring[current_player;main]" .. - "listring[context;dst]" .. - "listring[current_player;main]" .. - "image[0.22," .. (8.5 - bar_height) .. ";1," .. bar_height .. ";pipeworks_fluid_" .. (fluid or "air") .. ".png]" .. - "image[0.22,0.25;1,8.25;pipeworks_fluidbar.png]" - if minetest.get_modpath("digilines") then - fs = fs .. "field[1.47,4;4.5,0.75;channel;" .. S("Channel") .. - ";${channel}]" .. - "button[6.25,4;1.5,0.75;set_channel;" .. S("Set") .. "]" .. - "button_exit[8.05,4;2,0.75;close;" .. S("Close") .. "]" - end meta:set_string("formspec", fs) -- toggling the button doesn't quite call for running a recipe change check @@ -104,8 +78,13 @@ end -- Get best matching recipe for what user has put in crafting grid. -- This function does not consider crafting method (mix vs craft) -local function get_matching_craft(output_name, example_recipe) - local recipes = minetest.get_all_craft_recipes(output_name) +local function get_matching_craft(output_name, example_recipe, fluid_input) + local recipes + if fluid_input then + recipes = pipeworks.fluid_recipes:get_all(output_name) + else + recipes = minetest.get_all_craft_recipes(output_name) + end if not recipes then return example_recipe end @@ -154,21 +133,19 @@ local function get_craft(pos, inventory, hash) method = "normal", width = 3, items = example_recipe }) - if (not output) or (output.item:is_empty()) then - example_recipe[#example_recipe + 1] = ItemStack("air 65535") - output, decremented_input = core.get_craft_result({ - method = "normal", width = 3, items = example_recipe -- GOHERE + if (not output) or output.item:is_empty() then + output, decremented_input, fluid = pipeworks.fluid_recipes:get({ + shaped = true, items = example_recipe -- GOHERE }) end - pipeworks.fluid_recipes.take_fluid(decremented_input.items) local recipe = example_recipe if output and not output.item:is_empty() then - recipe = get_matching_craft(output.item:get_name(), example_recipe) + recipe = get_matching_craft(output.item:get_name(), example_recipe, fluid) end craft = { - fluid = pipeworks.fluid_recipes.take_fluid(recipe), + fluid = fluid, recipe = recipe, consumption = count_index(recipe), output = output, @@ -481,39 +458,85 @@ local function upgrade_autocrafter(pos, meta) end end -pipeworks.fluid_recipes = {} - -pipeworks.fluid_recipes.take_fluid = function(recipe) - local stack = recipe[#recipe][1] - if stack == nil then stack = recipe[#recipe] end - if type(stack) == "userdata" then - if stack:get_name() ~= "air" then return end - stack = stack:get_count() +pipeworks.fluid_recipes = { + trie = {} +} + +--[[def = {items = { + +}, +output = out|{outs}, -- Itemstacks +fluid = { + type = , + amount = +}} +]] +pipeworks.fluid_recipes.register = function(self, def) + if def.output == nil then return end + if def.items == nil then return end + local newdef = { + items = {}, + fluid = def.fluid, + shaped = def.shaped + } + local path = self.trie + for _,v in ipairs(def.items) do + if type(v) == "table" then + for i = 0, 2 do + if not v[i] then error("Invalid recipe! (nil stack)") end + newdef.items[#newdef.items + 1] = v[i] + local child = {} + path[v[i]] = {slot = #newdef.items, [#newdef.items] = child} + path = child + end + else + newdef.items[#newdef.items + 1] = v + local child = {} + path[v] = {slot = #newdef.items, [#newdef.items] = child} + path = child + end + end + if type(def.output) == "table" then + newdef.output = def.output else - stack = string.split(stack, " ") - if stack[1] ~= "air" then return end - stack = stack[2] + newdef.output = {item = def.output} end - local fluid = pipeworks.fluid_recipes[tonumber(stack)] - recipe[#recipe] = nil - return fluid + path.fluid = newdef.fluid + path.output = newdef.output + path.tail = true + self[#self + 1] = newdef end -local modify_recipe = function(recipe, fluid) - local modified_recipe = table.copy(recipe) - if type(fluid) == "number" then - -- do not use this unless you know what you are doing - modified_recipe.recipe[#modified_recipe.recipe + 1] = {"air " .. fluid} - else - pipeworks.fluid_recipes[#pipeworks.fluid_recipes + 1] = fluid - modified_recipe.recipe[#modified_recipe.recipe + 1] = {"air " .. #pipeworks.fluid_recipes} +--[[ input = { + input = , + shaped = -- doesn't really work for shapeless +} ]] +pipeworks.fluid_recipes.get = function(self, input) + local path = self.trie + local dec_input = table.copy(input) + for k,v in ipairs(dec_input.items) do + path = path[v:get_name()] + if dec_input.shaped then + path = path[k] + else + path = path[path.slot] + end + v:set_count(v:get_count()-1) + if path == nil then return nil, input end + if path.tail then return path.output, dec_input, path.fluid end end - modified_recipe.type = "shaped" - return modified_recipe + return nil, input end -pipeworks.register_fluid_recipe = function(recipe, fluid) - core.register_craft(modify_recipe(recipe, fluid)) +-- name = +pipeworks.fluid_recipes.get_all = function(self, name) + local out = {} + for _,v in ipairs(self) do + if v.output.item:get_name() == name then + out[#out + 1] = v + end + end + return out end minetest.register_node("pipeworks:autocrafter", { From 02bb507dc32e28819890767a1f1c3e74661646fa Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 03:38:04 -0500 Subject: [PATCH 11/54] update crafts --- crafts.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/crafts.lua b/crafts.lua index d35e4c9e..d8d01207 100644 --- a/crafts.lua +++ b/crafts.lua @@ -333,16 +333,14 @@ elseif core.get_modpath("mcl_buckets") then end if buckets.air and buckets.water then -local fluid = {type = "water", amount = 1} -local recipe = { - output = buckets.water, - recipe = { - {buckets.air}, - {""}, - {""} + local def = { + fluid = {type = "water", amount = 1}, + output = ItemStack(buckets.water), + items = { + buckets.air, "", "", "", "", "", "", "", "" + } } -} -pipeworks.register_fluid_recipe(recipe, fluid) +pipeworks.fluid_recipes:register(def) end end From 4348a21fd2bab20d73c9dd489ac72593d9e3302a Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 03:41:48 -0500 Subject: [PATCH 12/54] fix offsets --- common.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.lua b/common.lua index 4d4ac6f6..a6e3fe86 100644 --- a/common.lua +++ b/common.lua @@ -234,7 +234,7 @@ function fs_helpers.get_inv(y,x) table.insert(fs, "style_type[box;colors=#666]") for i=0, 2 do for j=0, hotbar_len - 1 do - table.insert(fs, "box["..0.2+(j*(spacing+size))..","..(inv_y+size+spacing+0.05)+(i*(spacing+size))..";"..size..","..size..";]") + table.insert(fs, "box["..inv_x+(j*(spacing+size))..","..(inv_y+size+spacing+0.05)+(i*(spacing+size))..";"..size..","..size..";]") end end @@ -259,7 +259,7 @@ function fs_helpers.get_inv(y,x) table.insert(fs, "style_type[box;colors=#666]") for i=0, 2 do for j=0, hotbar_len - 1 do - table.insert(fs, "box["..0.2+(j*(spacing+size))..","..(inv_y+size+spacing+0.05)+(i*(spacing+size))..";"..size..","..size..";]") + table.insert(fs, "box["..inv_x+(j*(spacing+size))..","..(inv_y+size+spacing+0.05)+(i*(spacing+size))..";"..size..","..size..";]") end end From 8961f1aa29221b8161dd554cd46698f72349bc61 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 06:18:57 -0500 Subject: [PATCH 13/54] flow sensor info --- devices.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/devices.lua b/devices.lua index afd1c7f8..c1e8cf18 100644 --- a/devices.lua +++ b/devices.lua @@ -605,7 +605,16 @@ new_flow_logic_register.directional_horizonal_rotate(nodename_sensor_loaded, tru -- activate flow sensor at roughly half the pressure pumps drive pipes local sensor_pressure_set = { { nodename_sensor_empty, 0.0 }, { nodename_sensor_loaded, 1.0 } } new_flow_logic_register.transition_simple_set(sensor_pressure_set, { mesecons=pipeworks.mesecons_rules }) - +core.register_abm({ + label = "flow sensor info", + nodenames = { "pipeworks:flow_sensor_empty", "pipeworks:flow_sensor_loaded" }, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + meta = core.get_meta(pos) + meta:set_string("infotext", S("Pressure: @1", meta:get("pipeworks.water_pressure"))) + end +}) -- tanks From 976c9714ab998386c586ebe100b52bf03eb6d516 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 06:28:41 -0500 Subject: [PATCH 14/54] don't global --- devices.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devices.lua b/devices.lua index c1e8cf18..2fb25fc9 100644 --- a/devices.lua +++ b/devices.lua @@ -611,7 +611,7 @@ core.register_abm({ interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) - meta = core.get_meta(pos) + local meta = core.get_meta(pos) meta:set_string("infotext", S("Pressure: @1", meta:get("pipeworks.water_pressure"))) end }) From a4f1a35067b9b26756aa8b984f324874448efcf8 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 06:55:18 -0500 Subject: [PATCH 15/54] stuff --- autocrafter.lua | 96 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 75 insertions(+), 21 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index c3d372e8..2e388d1c 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -45,6 +45,32 @@ local function update_meta(meta, enabled) local amount = meta:get_float("fluidamount") local fluid_cap = meta:get_float("fluidcap") local bar_height = 8.25 * amount / fluid_cap + local fs = + "formspec_version[4]" .. + "size[" .. size .. "]" .. + pipeworks.fs_helpers.get_prepends(size) .. + list_backgrounds .. + "list[context;recipe;1.47,0.22;3,3;]" .. + "image[5.25,1.45;1,1;[combine:16x16^[noalpha^[colorize:#141318:255]" .. + "list[context;output;5.25,1.45;1,1;]" .. + "image_button[5.25,2.6;1,0.6;pipeworks_button_" .. state .. ".png;" .. + state .. ";;;false;pipeworks_button_interm.png]" .. + "list[context;dst;6.53,0.22;4,3;]" .. + "list[context;src;1.47,5;8,3;]" ..-- + pipeworks.fs_helpers.get_inv(9,1.25) .. + "listring[current_player;main]" .. + "listring[context;src]" .. + "listring[current_player;main]" .. + "listring[context;dst]" .. + "listring[current_player;main]" .. + "image[0.22," .. (8.5 - bar_height) .. ";1," .. bar_height .. ";pipeworks_fluid_" .. (fluid or "air") .. ".png]" .. + "image[0.22,0.25;1,8.25;pipeworks_fluidbar.png]" + if minetest.get_modpath("digilines") then + fs = fs .. "field[1.47,4;4.5,0.75;channel;" .. S("Channel") .. + ";${channel}]" .. + "button[6.25,4;1.5,0.75;set_channel;" .. S("Set") .. "]" .. + "button_exit[8.05,4;2,0.75;close;" .. S("Close") .. "]" + end meta:set_string("formspec", fs) -- toggling the button doesn't quite call for running a recipe change check @@ -81,7 +107,7 @@ end local function get_matching_craft(output_name, example_recipe, fluid_input) local recipes if fluid_input then - recipes = pipeworks.fluid_recipes:get_all(output_name) + recipes = pipeworks.fluid_recipes:get_all(output_name, fluid_input.type) else recipes = minetest.get_all_craft_recipes(output_name) end @@ -120,6 +146,7 @@ local function get_matching_craft(output_name, example_recipe, fluid_input) end end + return best_index and recipes[best_index].items or example_recipe end @@ -133,9 +160,10 @@ local function get_craft(pos, inventory, hash) method = "normal", width = 3, items = example_recipe }) + local fluid if (not output) or output.item:is_empty() then output, decremented_input, fluid = pipeworks.fluid_recipes:get({ - shaped = true, items = example_recipe -- GOHERE + items = example_recipe, fluid_type = core.get_meta(pos):get("fluidtype") -- GOHERE }) end @@ -144,6 +172,7 @@ local function get_craft(pos, inventory, hash) recipe = get_matching_craft(output.item:get_name(), example_recipe, fluid) end + core.log(dump(decremented_input)) craft = { fluid = fluid, recipe = recipe, @@ -480,59 +509,75 @@ pipeworks.fluid_recipes.register = function(self, def) shaped = def.shaped } local path = self.trie + for _,v in ipairs(def.items) do if type(v) == "table" then - for i = 0, 2 do - if not v[i] then error("Invalid recipe! (nil stack)") end - newdef.items[#newdef.items + 1] = v[i] + for _,w in ipairs(v) do + newdef.items[#newdef.items + 1] = w local child = {} - path[v[i]] = {slot = #newdef.items, [#newdef.items] = child} + if path[w] then + child = path[w] + end + path[w] = child path = child end else newdef.items[#newdef.items + 1] = v local child = {} - path[v] = {slot = #newdef.items, [#newdef.items] = child} + if path[v] then + child = path[v] + end + path[v] = child path = child end end + if type(def.output) == "table" then newdef.output = def.output else newdef.output = {item = def.output} end - path.fluid = newdef.fluid - path.output = newdef.output + + if not path.fluid then path.fluid = {} end + if not path.output then path.output = {} end + + path.fluid[newdef.fluid.type] = newdef.fluid + path.output[newdef.fluid.type] = newdef.output path.tail = true self[#self + 1] = newdef end --[[ input = { input = , - shaped = -- doesn't really work for shapeless + fluid_type = } ]] pipeworks.fluid_recipes.get = function(self, input) local path = self.trie + local empty = {item = ItemStack("")} local dec_input = table.copy(input) for k,v in ipairs(dec_input.items) do path = path[v:get_name()] - if dec_input.shaped then - path = path[k] - else - path = path[path.slot] + if path == nil then return empty, input end + dec_input.items[k] = ItemStack(v) + dec_input.items[k]:set_count(v:get_count()-1) + if path == nil then return empty, input end + if path.tail then + if path.output[dec_input.fluid_type] then + return path.output[dec_input.fluid_type], dec_input, path.fluid[dec_input.fluid_type] + else + return empty, input + end end - v:set_count(v:get_count()-1) - if path == nil then return nil, input end - if path.tail then return path.output, dec_input, path.fluid end end - return nil, input + return empty, input end -- name = -pipeworks.fluid_recipes.get_all = function(self, name) +-- fluid_type = +pipeworks.fluid_recipes.get_all = function(self, name, fluid_type) local out = {} for _,v in ipairs(self) do - if v.output.item:get_name() == name then + if v.output[fluid_type] and v.output[fluid_type].item:get_name() == name then out[#out + 1] = v end end @@ -743,10 +788,19 @@ minetest.register_node("pipeworks:autocrafter", { -- autocrafter fluid stuff local autocraftername = "pipeworks:autocrafter" pipeworks.flowables.register.simple(autocraftername) -pipeworks.flowables.register.output(autocraftername, 0, 0, function(pos, node, currentpressure, finitemode) +pipeworks.flowables.register.output(autocraftername, 0, 0, function(pos, node, currentpressure, finitemode, fluid_type) -- "fluid_type" doesn't work, though it's a placeholder + local fluid_type = fluid_type or "water" local meta = core.get_meta(pos) local fluid_cap = meta:get_float("fluidcap") local fluid_amount = meta:get_float("fluidamount") + local current_fluid_type = meta:get("fluidtype") + if (current_fluid_type != fluid_type) then + if fluid_amount == 0 then + meta:set_string("fluidtype", fluid_type) + else + return 0 + end + end local taken = math.min(fluid_cap - fluid_amount, currentpressure) meta:set_float("fluidamount", fluid_amount + taken) update_meta(meta, meta:get_int("enabled") == 1) From ff5015df2f7f00443f635455014c5a93c03a42cd Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 08:21:53 -0500 Subject: [PATCH 16/54] add lava and defs --- init.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/init.lua b/init.lua index b8957342..a5ea8ce3 100644 --- a/init.lua +++ b/init.lua @@ -10,12 +10,19 @@ pipeworks = { modpath = minetest.get_modpath("pipeworks"), liquids = { water = { + def = core.registered_nodes["mapgen_water_source"], source = minetest.registered_nodes["mapgen_water_source"].name, flowing = minetest.registered_nodes["mapgen_water_source"].liquid_alternative_flowing }, river_water = { + def = core.registered_nodes["mapgen_river_water_source"], source = minetest.registered_nodes["mapgen_river_water_source"].name, flowing = minetest.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing + }, + lava = { + def = core.registered_nodes["mapgen_lava_source"], + source = core.registered_nodes["mapgen_lava_source"].name, + flowing = core.registered_nodes["mapgen_lava_source"].liquid_alternative_flowing } } } From c023b393c682cfbe80bd4e23f3416a82fc86371e Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 09:37:58 -0500 Subject: [PATCH 17/54] Update autocrafter.lua --- autocrafter.lua | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/autocrafter.lua b/autocrafter.lua index 2e388d1c..9b4fcd85 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -1,4 +1,35 @@ local S = minetest.get_translator("pipeworks") + +core.register_craftitem("pipeworks:text_req", { + description = S("Requirements"), + inventory_image = "text_req.png", + groups = {not_in_creative_inventory = 1}, + stack_max = 1, +}) + +core.register_craftitem("pipeworks:text_div1000", { + description = S("Liters (divide by 1000 for m³)"), + inventory_image = "text_div1000.png", + groups = {not_in_creative_inventory = 1}, + stack_max = 1, +}) + +if core.get_modpath("unified_inventory") then + unified_inventory.register_craft_type("fluidshaped", { + description = S("Shaped Fluid Craft"), + icon = "pipeworks_autocrafter.png", + width = 3, + height = 4, + }) + unified_inventory.register_on_craft_registered( + function (item_name, options) + if options.type ~= "fluidshaped" then return end + options.items[10] = "pipeworks:text_req" + options.items[11] = pipeworks.liquids[options.fluid.type].source .. " " .. (options.fluid.amount * 1000) + options.items[12] = "pipeworks:text_div1000" + end + ) +end -- cache some recipe data to avoid calling the slow function -- minetest.get_craft_result() every second local autocrafterCache = {} @@ -532,6 +563,16 @@ pipeworks.fluid_recipes.register = function(self, def) end end + if core.get_modpath("unified_inventory") then + unified_inventory.register_craft({ + output = def.output, + type = "fluidshaped", + items = newdef.items, + fluid = newdef.fluid, + width = 3, + }) + end + if type(def.output) == "table" then newdef.output = def.output else @@ -794,7 +835,7 @@ pipeworks.flowables.register.output(autocraftername, 0, 0, function(pos, node, c local fluid_cap = meta:get_float("fluidcap") local fluid_amount = meta:get_float("fluidamount") local current_fluid_type = meta:get("fluidtype") - if (current_fluid_type != fluid_type) then + if current_fluid_type ~= fluid_type then if fluid_amount == 0 then meta:set_string("fluidtype", fluid_type) else From 1e70b481807f6a415de8d3af4c48671964760e3b Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 09:40:28 -0500 Subject: [PATCH 18/54] remove unnecessary registration --- autocrafter.lua | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 9b4fcd85..350fc3f8 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -1,26 +1,27 @@ local S = minetest.get_translator("pipeworks") -core.register_craftitem("pipeworks:text_req", { - description = S("Requirements"), - inventory_image = "text_req.png", - groups = {not_in_creative_inventory = 1}, - stack_max = 1, -}) - -core.register_craftitem("pipeworks:text_div1000", { - description = S("Liters (divide by 1000 for m³)"), - inventory_image = "text_div1000.png", - groups = {not_in_creative_inventory = 1}, - stack_max = 1, -}) - if core.get_modpath("unified_inventory") then + core.register_craftitem("pipeworks:text_req", { + description = S("Requirements"), + inventory_image = "text_req.png", + groups = {not_in_creative_inventory = 1}, + stack_max = 1, + }) + + core.register_craftitem("pipeworks:text_div1000", { + description = S("Liters (divide by 1000 for m³)"), + inventory_image = "text_div1000.png", + groups = {not_in_creative_inventory = 1}, + stack_max = 1, + }) + unified_inventory.register_craft_type("fluidshaped", { description = S("Shaped Fluid Craft"), icon = "pipeworks_autocrafter.png", width = 3, height = 4, }) + unified_inventory.register_on_craft_registered( function (item_name, options) if options.type ~= "fluidshaped" then return end From 4a8bf02e148305c27cd9715bcf3d56bf2ab9762c Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 09:44:46 -0500 Subject: [PATCH 19/54] Add files via upload --- textures/pipeworks_fluid_lava.png | Bin 0 -> 83 bytes textures/pipeworks_fluid_river_water.png | Bin 0 -> 83 bytes textures/text_div1000.png | Bin 0 -> 902 bytes textures/text_req.png | Bin 0 -> 2090 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 textures/pipeworks_fluid_lava.png create mode 100644 textures/pipeworks_fluid_river_water.png create mode 100644 textures/text_div1000.png create mode 100644 textures/text_req.png diff --git a/textures/pipeworks_fluid_lava.png b/textures/pipeworks_fluid_lava.png new file mode 100644 index 0000000000000000000000000000000000000000..c06d44c9dda8d36ce527a2c1f090063c8879d04e GIT binary patch literal 83 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k92}K#X;^)4C~IxyaaN1JzX3_IA$hS d#4i3J&%l<()KT9ctPhl6@O1TaS?83{1ORy*5-I=y literal 0 HcmV?d00001 diff --git a/textures/pipeworks_fluid_river_water.png b/textures/pipeworks_fluid_river_water.png new file mode 100644 index 0000000000000000000000000000000000000000..90e78df1bc462d2d791dee23764c93528ae6f216 GIT binary patch literal 83 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k92}K#X;^)4C~IxyaaN1JzX3_IA$hq dh%0_+&%io^X{Vr1$wQz7gQu&X%Q~loCIE*V6Bhsg literal 0 HcmV?d00001 diff --git a/textures/text_div1000.png b/textures/text_div1000.png new file mode 100644 index 0000000000000000000000000000000000000000..800bf95451aca3af6e999780acc78d589b135509 GIT binary patch literal 902 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G!U;i$lZxy-8q?;3=GT;o-U3d z6?5L+ImpXoz{9YSZR7t_iR>&|FWxX-+T&MQdd{-CVaf5gtPRyH42K3Mns>i0q1@iC zIL*#ZxGRQ1Ky4HarV#kHXYT>)vhUxx?32^-)*p~BW^|arKpMI+r?_T4bD$mrhwvan a)r{sfT#UAlZsr0r7K5j&pUXO@geCxXwTmGD literal 0 HcmV?d00001 diff --git a/textures/text_req.png b/textures/text_req.png new file mode 100644 index 0000000000000000000000000000000000000000..d8d1b5f00a42e32acbe18206c1cb8227925135ca GIT binary patch literal 2090 zcmd6o`8V8$8phx6n8Z+GtH@$W;+DqVR*_E4NUE5KwU$T>V!||HVh=(Xq-|6~l~_|t z+~V41m>ZR(3?jzXA#!DiWhTf)jgcV?`7$c!+}_i3?jLab)BC*VJ?}5idCv1mcXhT` zls_a70E#3BTXz6tS0aGhyE}X%tApQeQSSDqpnM;^{?G} z`cQULWcIVB;e$RHd8;aEYgko%$GdB80dn>IO`q;RGRziDfq;O44lJa~0agugdZ2s; zjue268A1>Ee;=f+5?P%rPR~-@WipRUlw3jA+os&SX@l82gPxQ(ua}kyArD1|(7vm( z@L&`Fw^V^DJs^uSv*PLUF~;VXS!En-Wgkd+Apu|SwR=HAgNch;jjhX4a$kf{?}&<@ ze)M#qR4X64{;{F|!4vm}HNFaLJQmgha>Q@Nzy<_qh297T97VhO zKL(i&T+`V-WObqNU#kvFBLvx&j;f4a!D+8Qo2e}?-%vsA&e|noS#B z++^SC-SNkSm-F}4=&CsQcV7|5eJW&VJR&OgBxP|ZtA+aFrP}kfA77DBV-u)YWUmGI z@YZ;=IO)$WjD&6<;ecaya%A+~N$b3iZoXrqVXq|WO542oukDxG?TTE&sJqg?t)Io* zn)3Go%XsZ*?TRF8bm1GA2(`s&4zXFuQ|I%8#Fp8CZRsg#MJl^dx-WqW@liJkXrtkuG2twh(2UwpZrUS%zFg*g}@nI*m{ zTHt)%4@UjJ@P=9Vs0mHA@q3COsofBhYah|h$p*|?E<`pM4syLP{L5M(`og->c_07y z4z=BdaDCE35@k0vHyL3anS2gm`s53)Dh^h;xMgnT{siGQ&N<9eqs^g@ZZ4_A`+85S_Y~+PCCZs7ISA!_2)a5M3cV)xu^Yj? zZIblrNfX%zG}9_2U|Jea9dx|FK=4n{j9Nv|s&6#>PdR zGO?YaM?J0swP5A42}T(>kMEg{lvm#kyyxhB? z&mf|g#_fbe{qJ<1Vg>Uj9Tcfq<-I%X$`nKgbAIx|u!Pe{>|--k{h7&im}SGso@a(WZ6ArgVw;Ab6lC z9cUoD6H8cJ9urlt7ju!(J_A7_)n$OIwlk8)ztGc~7UZM3Ju&SNM=cPR`igCok+K_M zl<&>Nj9JyUsHt!9|0wS*WXiC-b%`=Ok2q+S2}3{NzB>xJZZFWi!=1^9e? g;a`t}e`d3gxIrkle8@Ic--SPrK6kclI2DlkI~;I+v;Y7A literal 0 HcmV?d00001 From fadcae383394533bd85090f05eec910198d41886 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 09:48:20 -0500 Subject: [PATCH 20/54] recipes --- crafts.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/crafts.lua b/crafts.lua index d8d01207..9e3a9716 100644 --- a/crafts.lua +++ b/crafts.lua @@ -340,7 +340,27 @@ if buckets.air and buckets.water then buckets.air, "", "", "", "", "", "", "", "" } } -pipeworks.fluid_recipes:register(def) + pipeworks.fluid_recipes:register(def) +end +if buckets.air and buckets.lava then + local def = { + fluid = {type = "lava", amount = 1}, + output = ItemStack(buckets.lava), + items = { + buckets.air, "", "", "", "", "", "", "", "" + } + } + pipeworks.fluid_recipes:register(def) +end +if buckets.river_water and buckets.lava then + local def = { + fluid = {type = "river_water", amount = 0.5}, + output = ItemStack(buckets.river_water), + items = { + buckets.air, "", "", "", "", "", "", "", "" + } + } + pipeworks.fluid_recipes:register(def) end end From f1e78f0c8bddae104103547d2a363c7dbee09364 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 09:53:47 -0500 Subject: [PATCH 21/54] Update crafts.lua --- crafts.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crafts.lua b/crafts.lua index 9e3a9716..b48ec239 100644 --- a/crafts.lua +++ b/crafts.lua @@ -354,7 +354,7 @@ if buckets.air and buckets.lava then end if buckets.river_water and buckets.lava then local def = { - fluid = {type = "river_water", amount = 0.5}, + fluid = {type = "river_water", amount = 1}, output = ItemStack(buckets.river_water), items = { buckets.air, "", "", "", "", "", "", "", "" From 70bf3efaa70ca5b10618cc8ca393f304c6a6e68e Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 26 Apr 2025 10:28:25 -0500 Subject: [PATCH 22/54] enforcing load order --- mod.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod.conf b/mod.conf index 3f8158af..8b842460 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, xcompat, fakelib -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, mcl_barrels, mcl_furnaces, mcl_experience, vizlib +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, mcl_barrels, mcl_furnaces, mcl_experience, vizlib, bucket, mcl_buckets min_minetest_version = 5.5.0 From 9407ba3a8ffaa769be31c6b10bd946739423dae7 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 12:52:36 -0500 Subject: [PATCH 23/54] merge on_place and on_dig (contains leak from wip) --- trashcan.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trashcan.lua b/trashcan.lua index f014208d..01fca950 100644 --- a/trashcan.lua +++ b/trashcan.lua @@ -45,18 +45,18 @@ minetest.register_node(voidname, { meta:set_string("infotext", S("Trash Can")) meta:get_inventory():set_size("trash", 1) end, - after_place_node = pipeworks.after_place, - after_dig_node = pipeworks.after_dig, on_metadata_inventory_put = function(pos, listname, index, stack, player) minetest.get_meta(pos):get_inventory():set_stack(listname, index, ItemStack("")) end, after_place_node = function(pos) pipeworks.scan_for_pipe_objects(pos) + pipeworks.after_place(pos) end, after_dig_node = function(pos) pipeworks.scan_for_pipe_objects(pos) + pipeworks.after_dig(pos) end, }) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = voidname pipeworks.flowables.register.simple(voidname) -pipeworks.flowables.register.output(voidname, 0, 0, function() return 4 end, function()end) +pipeworks.flowables.register.output(voidname, 0, 0, function(pos, node, currentpressure, finitemode, currentfluidtype) return 4, currentfluidtype end, function()end) From 0a0bd361b078c78b0885df346f0bf9bfe8a9d86d Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 13:02:32 -0500 Subject: [PATCH 24/54] fix luacheck again --- common.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.lua b/common.lua index a6e3fe86..589cf419 100644 --- a/common.lua +++ b/common.lua @@ -219,8 +219,8 @@ function fs_helpers.get_inv(y,x) local inv_y = (y + 0.4) or 6.9 local size, spacing = 1, 0.1 local hotbar_len = i3.settings.hotbar_len or (i3.settings.legacy_inventory and 8 or 9) - local hotbar_width = 4 - local inv_size = i3.settings.inv_size or (hotbar_len * hotbar_width) + local hotbar_width = (i3.settings.inv_size and (i3.settings.inv_size/hotbar_len)) or 4 + --local inv_size = i3.settings.inv_size or (hotbar_len * hotbar_width) is useless table.insert(fs, "style_type[box;colors=#77777710,#77777710,#777,#777]") From d72b5408f51aa077ca0115d58d6fde29f4c1e616 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 13:04:35 -0500 Subject: [PATCH 25/54] remove space-only lines --- autocrafter.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 350fc3f8..844b51f4 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -2,7 +2,7 @@ local S = minetest.get_translator("pipeworks") if core.get_modpath("unified_inventory") then core.register_craftitem("pipeworks:text_req", { - description = S("Requirements"), + description = S("Requirements"), inventory_image = "text_req.png", groups = {not_in_creative_inventory = 1}, stack_max = 1, @@ -14,14 +14,14 @@ if core.get_modpath("unified_inventory") then groups = {not_in_creative_inventory = 1}, stack_max = 1, }) - + unified_inventory.register_craft_type("fluidshaped", { description = S("Shaped Fluid Craft"), icon = "pipeworks_autocrafter.png", width = 3, height = 4, }) - + unified_inventory.register_on_craft_registered( function (item_name, options) if options.type ~= "fluidshaped" then return end @@ -178,7 +178,6 @@ local function get_matching_craft(output_name, example_recipe, fluid_input) end end - return best_index and recipes[best_index].items or example_recipe end @@ -191,7 +190,7 @@ local function get_craft(pos, inventory, hash) local output, decremented_input = minetest.get_craft_result({ method = "normal", width = 3, items = example_recipe }) - + local fluid if (not output) or output.item:is_empty() then output, decremented_input, fluid = pipeworks.fluid_recipes:get({ From 92e7f29576e5e4e2e4e0a8a8eb576bc604667a03 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 13:08:50 -0500 Subject: [PATCH 26/54] Update .luacheckrc --- .luacheckrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.luacheckrc b/.luacheckrc index 79d6ae7f..916a0f83 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -5,7 +5,8 @@ std = "minetest+max" globals = { "pipeworks", - "luaentity" + "luaentity", + "core" } read_globals = { From ba8dc61d3517b2fa378d9873b1b5287c10a313fd Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:33:26 -0500 Subject: [PATCH 27/54] generalize flag --- autodetect-finite-water.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autodetect-finite-water.lua b/autodetect-finite-water.lua index d218e806..ddbbf96b 100644 --- a/autodetect-finite-water.lua +++ b/autodetect-finite-water.lua @@ -1,4 +1,4 @@ --- enable finite liquid in the presence of dynamic liquid to preserve water volume. +-- enable finite liquid in the presence of dynamic liquid to preserve fluid volume. local enable = false if minetest.get_modpath("dynamic_liquid") then @@ -6,4 +6,4 @@ if minetest.get_modpath("dynamic_liquid") then enable = true end -pipeworks.toggles.finite_water = enable +pipeworks.toggles.finite = enable From 03021219ff67b80ddbaad74816ca947e6eee358e Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:34:18 -0500 Subject: [PATCH 28/54] Update init.lua --- init.lua | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/init.lua b/init.lua index a5ea8ce3..6f0a69fb 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,5 @@ +local S = core.get_translator("pipeworks") + -- Pipeworks mod by Vanessa Ezekowitz - 2013-07-13 -- -- This mod supplies various steel pipes and plastic pneumatic tubes @@ -8,25 +10,27 @@ pipeworks = { ui_cat_tube_list = {}, worldpath = minetest.get_worldpath(), modpath = minetest.get_modpath("pipeworks"), - liquids = { - water = { - def = core.registered_nodes["mapgen_water_source"], - source = minetest.registered_nodes["mapgen_water_source"].name, - flowing = minetest.registered_nodes["mapgen_water_source"].liquid_alternative_flowing - }, - river_water = { - def = core.registered_nodes["mapgen_river_water_source"], - source = minetest.registered_nodes["mapgen_river_water_source"].name, - flowing = minetest.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing - }, - lava = { - def = core.registered_nodes["mapgen_lava_source"], - source = core.registered_nodes["mapgen_lava_source"].name, - flowing = core.registered_nodes["mapgen_lava_source"].liquid_alternative_flowing + register_fluid = function(self, alias, name, density, description) + local def = core.registered_nodes[alias] + self.liquids[name] = { + def = def, + source = def.liquid_alternative_source, + description = description or string.gsub(def.description, "%s?"..S("Source").."%s?", ""), + flowing = def.liquid_alternative_flowing, + density = density, -- in g/cm³ as standard } - } + self.fluid_types[def.liquid_alternative_source] = name + end, + liquids = {}, + fluid_types = {}, -- easier indexing + gravity = {x=0, y=-0.025, z=0}, -- pressure bias factor, SI unit unspecified } +-- fluid registration +pipeworks:register_fluid("mapgen_water_source", "water", 1.05, S("Water")) +pipeworks:register_fluid("mapgen_river_water_source", "river_water", 1, S("River Water")) +pipeworks:register_fluid("mapgen_lava_source", "lava", 4, S("Lava")) + dofile(pipeworks.modpath.."/default_settings.lua") -- Read the external config file if it exists. local worldsettingspath = pipeworks.worldpath.."/pipeworks_settings.txt" @@ -49,8 +53,8 @@ end ------------------------------------------- -- Load the various other parts of the mod --- early auto-detection for finite water mode if not explicitly disabled -if pipeworks.toggles.finite_water == nil then +-- early auto-detection for finite fluids mode if not explicitly disabled +if pipeworks.toggles.finite == nil then dofile(pipeworks.modpath.."/autodetect-finite-water.lua") end From a5439f28ae290a043cddac85f39b3797baa2eb4e Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:35:49 -0500 Subject: [PATCH 29/54] actual multifluid support --- autocrafter.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 844b51f4..269d154e 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -2,7 +2,7 @@ local S = minetest.get_translator("pipeworks") if core.get_modpath("unified_inventory") then core.register_craftitem("pipeworks:text_req", { - description = S("Requirements"), + description = S("Requirements"), inventory_image = "text_req.png", groups = {not_in_creative_inventory = 1}, stack_max = 1, @@ -14,14 +14,14 @@ if core.get_modpath("unified_inventory") then groups = {not_in_creative_inventory = 1}, stack_max = 1, }) - + unified_inventory.register_craft_type("fluidshaped", { description = S("Shaped Fluid Craft"), icon = "pipeworks_autocrafter.png", width = 3, height = 4, }) - + unified_inventory.register_on_craft_registered( function (item_name, options) if options.type ~= "fluidshaped" then return end @@ -178,6 +178,7 @@ local function get_matching_craft(output_name, example_recipe, fluid_input) end end + return best_index and recipes[best_index].items or example_recipe end @@ -190,7 +191,7 @@ local function get_craft(pos, inventory, hash) local output, decremented_input = minetest.get_craft_result({ method = "normal", width = 3, items = example_recipe }) - + local fluid if (not output) or output.item:is_empty() then output, decremented_input, fluid = pipeworks.fluid_recipes:get({ @@ -653,7 +654,6 @@ minetest.register_node("pipeworks:autocrafter", { on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_float("fluidcap", 8) - meta:set_string("fluidtype", "water") local inv = meta:get_inventory() inv:set_size("src", 3 * 8) inv:set_size("recipe", 3 * 3) @@ -829,8 +829,8 @@ minetest.register_node("pipeworks:autocrafter", { -- autocrafter fluid stuff local autocraftername = "pipeworks:autocrafter" pipeworks.flowables.register.simple(autocraftername) -pipeworks.flowables.register.output(autocraftername, 0, 0, function(pos, node, currentpressure, finitemode, fluid_type) -- "fluid_type" doesn't work, though it's a placeholder - local fluid_type = fluid_type or "water" +pipeworks.flowables.register.output(autocraftername, 0, 0, function(pos, node, currentpressure, finitemode, fluid_type) + if fluid_type == nil then return 0, fluid_type end -- you can't put empty in something and expect displacement local meta = core.get_meta(pos) local fluid_cap = meta:get_float("fluidcap") local fluid_amount = meta:get_float("fluidamount") @@ -839,13 +839,13 @@ pipeworks.flowables.register.output(autocraftername, 0, 0, function(pos, node, c if fluid_amount == 0 then meta:set_string("fluidtype", fluid_type) else - return 0 + return 0, fluid_type end end local taken = math.min(fluid_cap - fluid_amount, currentpressure) meta:set_float("fluidamount", fluid_amount + taken) update_meta(meta, meta:get_int("enabled") == 1) - return taken + return taken, fluid_type end, function()end) pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list + 1] = autocraftername From fe984adfcb22f4bf25715829afb3dcd8132e0b1b Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:38:42 -0500 Subject: [PATCH 30/54] casewise finity --- default_settings.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/default_settings.lua b/default_settings.lua index 81644497..4ba717d7 100644 --- a/default_settings.lua +++ b/default_settings.lua @@ -44,25 +44,32 @@ pipeworks.toggles = {} -- set to one of the following strings. -- "classic": classic mode written by VanessaE -- "pressure": pressure metadata based, written by thetaepsilon. --- has caveats such as water speed issues though. +-- has caveats such as fluid speed issues though. -- setting to nil inhibits all flow logic, useful for debugging ABM crashes, -- or for rendering the pipes purely decorative. ]] pipeworks.toggles.pipe_mode = "pressure" --[[ --- force-enable finite water handling mode. --- this changes the way that water node placement is handled; +-- force-enable finite fluid handling mode. +-- this changes the way that fluid node placement is handled; -- volume will always be preserved, --- and water is assumed to move itself downwards. +-- and fluid is assumed to move itself downwards. -- nil (the default) means autodetect from installed finite liquid mods, -- true is force-on, false is force-off. -- note that you should NOT normally explicitly set this to true/false, -- unless the mod you want this for is not covered by auto-detection -- (please see autodetect-finite-water.lua). --- please file an issue if you have a finite water mod not covered there, +-- please file an issue if you have a finite fluid mod not covered there, -- and feel it necessary to explicitly set this toggle -pipeworks.toggles.finite_water = nil +pipeworks.toggles.finite = nil ]] +-- casewise finite fluid toggles +-- can be overriden by setting toggles.finite to true +pipeworks.toggles.finites = { + water = false, + river_water = true, + lava = true, +} for name, value in pairs(settings) do local setting_type = type(value) From 5e57cc30433ff26d749838563b7b4ff8f4cab8c0 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:39:11 -0500 Subject: [PATCH 31/54] try dehardcoding possibly useless code --- flowing_logic.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/flowing_logic.lua b/flowing_logic.lua index b1c12aac..608238cd 100644 --- a/flowing_logic.lua +++ b/flowing_logic.lua @@ -4,7 +4,7 @@ -- Contributed by mauvebic, 2013-01-03, rewritten a bit by Vanessa Ezekowitz -- -local finitewater = minetest.settings:get_bool("liquid_finite") +local finite = minetest.settings:get_bool("liquid_finite") pipeworks.check_for_liquids = function(pos) local coords = { @@ -16,12 +16,12 @@ pipeworks.check_for_liquids = function(pos) {x=pos.x,y=pos.y,z=pos.z+1}, } for i =1,6 do local name = minetest.get_node(coords[i]).name - if name and string.find(name,"water") then - if finitewater then minetest.remove_node(coords[i]) end - return true + if name and pipeworks.fluid_types[name] then + if finite then minetest.remove_node(coords[i]) end + return pipeworks.fluid_types[name] end end - return false + return nil end pipeworks.check_for_inflows = function(pos,node) @@ -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 == pipeworks.liquids.water.flowing or belowname == pipeworks.liquids.water.source) then + if belowname and (belowname == "air" or core.registered_nodes[name].liquid_alternative_flowing) 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 ~= pipeworks.liquids.water.source then + if finite 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 == pipeworks.liquids.water.source and not finitewater then + if belowname == pipeworks.liquids.water.source and not finite then minetest.remove_node({x=pos.x,y=pos.y-1,z=pos.z}) end end @@ -119,14 +119,14 @@ pipeworks.fountainhead_check = function(pos, node) 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 ~= pipeworks.liquids.water.source then + if finite 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 == pipeworks.liquids.water.source and not finitewater then + if abovename == pipeworks.liquids.water.source and not finite then minetest.remove_node({x=pos.x,y=pos.y+1,z=pos.z}) end end From e221eca40d743b7e97ced2e286372a2a91eec814 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:39:37 -0500 Subject: [PATCH 32/54] sensor show type --- devices.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/devices.lua b/devices.lua index 2fb25fc9..2f788d5c 100644 --- a/devices.lua +++ b/devices.lua @@ -151,7 +151,7 @@ core.register_node(sourcename, { }) new_flow_logic_register.simple(sourcename) -new_flow_logic_register.intake(sourcename, 4, function() return 4 end) +new_flow_logic_register.intake(sourcename, 4, function() return 4, "water" end) local states = { "on", "off" } @@ -396,7 +396,7 @@ minetest.register_node(nodename_spigot_loaded, { drawtype = "mesh", mesh = "pipeworks_spigot_pouring"..polys..".obj", tiles = { - minetest.registered_nodes[pipeworks.liquids.water.source].tiles[1], + pipeworks.liquids.water.def.tiles[1], { name = "pipeworks_spigot.png" } }, use_texture_alpha = texture_alpha_mode and "blend" or true, @@ -612,7 +612,8 @@ core.register_abm({ chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local meta = core.get_meta(pos) - meta:set_string("infotext", S("Pressure: @1", meta:get("pipeworks.water_pressure"))) + local fluid_def = pipeworks.liquids[meta:get("pipeworks.fluid_type")] + meta:set_string("infotext", S("@1: @2", (fluid_def and fluid_def.description) or S("none"), (meta:get("pipeworks.pressure") or 0))) end }) From fb5aa1f9422c18f822d5276c35bb779e79713845 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:40:32 -0500 Subject: [PATCH 33/54] =?UTF-8?q?semantic=20changes=20(water=20=E2=86=92?= =?UTF-8?q?=20fluid)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pressure_logic/flowable_node_registry.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pressure_logic/flowable_node_registry.lua b/pressure_logic/flowable_node_registry.lua index 6d7bf173..ee7a531d 100644 --- a/pressure_logic/flowable_node_registry.lua +++ b/pressure_logic/flowable_node_registry.lua @@ -35,7 +35,7 @@ pipeworks.flowables.list.simple_nodenames = {} -- the neighbour is to participate in pressure balancing. pipeworks.flowables.list.directional = {} --- simple intakes - try to absorb any adjacent water nodes +-- simple intakes - try to absorb any adjacent fluid nodes pipeworks.flowables.inputs = {} pipeworks.flowables.inputs.list = {} pipeworks.flowables.inputs.nodenames = {} From 329bff4c34547977ab91dedca23ce5b81b326e86 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:41:16 -0500 Subject: [PATCH 34/54] support for existing stuff for multitype --- pressure_logic/flowable_node_registry_install.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pressure_logic/flowable_node_registry_install.lua b/pressure_logic/flowable_node_registry_install.lua index b561ca64..0b3c7b30 100644 --- a/pressure_logic/flowable_node_registry_install.lua +++ b/pressure_logic/flowable_node_registry_install.lua @@ -143,7 +143,7 @@ end -- Register a node as a simple intake: --- tries to absorb water source nodes from it's surroundings. +-- tries to absorb fluid source nodes from it's surroundings. -- may exceed limit slightly due to needing to absorb whole nodes. register.intake_simple = function(nodename, maxpressure) register.intake(nodename, maxpressure, pipeworks.flowlogic.check_for_liquids_v2) @@ -157,10 +157,10 @@ end -- if not (the default unless auto-detected), -- nodes above their upper threshold have their outputfn invoked (and pressure deducted), -- nodes between upper and lower are left idle, --- and nodes below lower have their cleanup fn invoked (to say remove water sources). +-- and nodes below lower have their cleanup fn invoked (to say remove fluid sources). -- the upper and lower difference acts as a hysteresis to try and avoid "gaps" in the flow. -- if finite mode is on, upper is ignored and lower is used to determine whether to run outputfn; --- cleanupfn is ignored in this mode as finite mode assumes something causes water to move itself. +-- cleanupfn is ignored in this mode as finite mode assumes something causes fluid to move itself. register.output = function(nodename, upper, lower, outputfn, cleanupfn) if pipeworks.flowables.outputs.list[nodename] then error("pipeworks.flowables.outputs duplicate registration!") From 35ab87dbc011fe0f9cbea2c856b3b83f439fe783 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:44:47 -0500 Subject: [PATCH 35/54] a WHOLE lot --- pressure_logic/abms.lua | 231 ++++++++++++++++++++++++++++++---------- 1 file changed, 173 insertions(+), 58 deletions(-) diff --git a/pressure_logic/abms.lua b/pressure_logic/abms.lua index bf9c2db0..547c38d2 100644 --- a/pressure_logic/abms.lua +++ b/pressure_logic/abms.lua @@ -34,29 +34,39 @@ end -- new version of liquid check --- accepts a limit parameter to only delete water blocks that the receptacle can accept, +-- accepts a limit parameter to only delete fluid blocks that the receptacle can accept, -- and returns it so that the receptacle can update it's pressure values. -local check_for_liquids_v2 = function(pos, limit) +local check_for_liquids_v2 = function(pos, limit, current_type) + if limit == 0 then return 0, current_type end local coords = make_coords_offsets(pos, false) local total = 0 + local fluid_type = (core.get_meta(pos):get_float("pipeworks.pressure") > 0.001) and current_type + local fluid_nodename = fluid_type and pipeworks.liquids[current_type].source for _, tpos in ipairs(coords) do - if total >= limit then break end local name = minetest.get_node(tpos).name - if name == pipeworks.liquids.water.source then - minetest.remove_node(tpos) - total = total + 1 + if name == core.registered_nodes[name].liquid_alternative_source then -- if node is fluid source + if not fluid_type then + fluid_type = pipeworks.fluid_types[name] + if fluid_type then fluid_nodename = name end + end + if name == fluid_nodename then + core.remove_node(tpos) + total = total + 1 + if total >= limit then break end + end end end --pipeworks.logger("check_for_liquids_v2@"..formatvec(pos).." total "..total) - return total + + return total, fluid_type end flowlogic.check_for_liquids_v2 = check_for_liquids_v2 -local label_pressure = "pipeworks.water_pressure" +local label_pressure = "pipeworks.pressure" local get_pressure_access = function(pos) - local metaref = minetest.get_meta(pos) + local metaref = core.get_meta(pos) return { get = function() return metaref:get_float(label_pressure) @@ -67,6 +77,18 @@ local get_pressure_access = function(pos) } end +local label_type = "pipeworks.fluid_type" +local get_fluid_type_access = function(pos) + local metaref = core.get_meta(pos) + return { + get = function() + return metaref:get(label_type) + end, + set = function(v) + metaref:set_string(label_type, v) + end + } +end -- logging is unreliable when something is crashing... --[[ @@ -79,47 +101,53 @@ end -local finitemode = pipeworks.toggles.finite_water +local finitemode = pipeworks.toggles.finite +local finites = pipeworks.toggles.finites flowlogic.run = function(pos, node) local nodename = node.name -- get the current pressure value. local nodepressure = get_pressure_access(pos) local currentpressure = nodepressure.get() local oldpressure = currentpressure + local nodefluidtype = get_fluid_type_access(pos) + local currentfluidtype = nodefluidtype.get() + local finitemode = finitemode or finites[currentfluidtype] -- if node is an input: run intake phase local inputdef = pipeworks.flowables.inputs.list[nodename] if inputdef then - currentpressure = flowlogic.run_input(pos, node, currentpressure, inputdef) + currentpressure, currentfluidtype = flowlogic.run_input(pos, node, currentpressure, inputdef, currentfluidtype) --debuglog("post-intake currentpressure is "..currentpressure) --nilexplode("run()", "currentpressure", currentpressure) end -- balance pressure with neighbours - currentpressure = flowlogic.balance_pressure(pos, node, currentpressure) + currentpressure, currentfluidtype = flowlogic.balance_pressure(pos, node, currentpressure, currentfluidtype) -- if node is an output: run output phase local outputdef = pipeworks.flowables.outputs.list[nodename] if outputdef then - currentpressure = flowlogic.run_output( + currentpressure, currentfluidtype = flowlogic.run_output( pos, node, currentpressure, oldpressure, outputdef, - finitemode) + finitemode, + currentfluidtype) end -- if node has pressure transitions: determine new node if pipeworks.flowables.transitions.list[nodename] then - local newnode = flowlogic.run_transition(node, currentpressure) + local newnode = flowlogic.run_transition(node, currentpressure, currentfluidtype) --pipeworks.logger("flowlogic.run()@"..formatvec(pos).." transition, new node name = "..dump(newnode).." pressure "..tostring(currentpressure)) minetest.swap_node(pos, newnode) flowlogic.run_transition_post(pos, newnode) end - -- set the new pressure + -- set the new pressure and type nodepressure.set(currentpressure) + nodefluidtype.set(currentfluidtype) end @@ -153,14 +181,17 @@ local get_neighbour_positions = function(pos, node) -- then, check each possible neighbour to see if they can be reached from this node. local connections = {} + local tconnections = {} + local offsets = {} for _, offset in ipairs(candidates) do local npos = vector.add(pos, offset) local neighbour = minetest.get_node(npos) local nodename = neighbour.name local is_simple = (pipeworks.flowables.list.simple[nodename]) if is_simple then - local n = get_pressure_access(npos) - table.insert(connections, n) + table.insert(connections, get_pressure_access(npos)) + table.insert(tconnections, get_fluid_type_access(npos)) + table.insert(offsets, offset) else -- if target node is also directional, check if it agrees it can flow in that direction local directional = pipeworks.flowables.list.directional[nodename] @@ -171,104 +202,187 @@ local get_neighbour_positions = function(pos, node) local result = directional.directionfn(neighbour, towards_origin) --pipeworks.logger(dname.."result: "..tostring(result)) if result then - local n = get_pressure_access(npos) - table.insert(connections, n) + table.insert(connections, get_pressure_access(npos)) + table.insert(tconnections, get_fluid_type_access(npos)) + table.insert(offsets, offset) end end end end - return connections + return connections, tconnections, offsets end -flowlogic.balance_pressure = function(pos, node, currentpressure) +flowlogic.balance_pressure = function(pos, node, currentpressure, currentfluidtype) + if not pipeworks.liquids[currentfluidtype] then return 0, nil end -- local dname = "flowlogic.balance_pressure()@"..formatvec(pos).." " -- check the pressure of all nearby flowable nodes, and average it out. -- unconditionally include self in nodes to average over. -- result of averaging will be returned as new pressure for main flow logic callback - local totalv = currentpressure - local totalc = 1 - + -- pressure handles to average over - local connections = get_neighbour_positions(pos, node) + local connections, tconnections, offsets = get_neighbour_positions(pos, node) + + if #connections == 0 then return currentpressure, currentfluidtype end + + local total_pressure = currentpressure + + -- cached values + local pressures = {} + local fluid_types = {} + local biases = {} + + -- same-type connections + local migrate = {} + + -- connections that force current fluid out + local intrusive = {} + + for k, connection in ipairs(connections) do + -- cache values + pressures[k] = connection.get() + fluid_types[k] = tconnections[k].get() + biases[k] = (pipeworks.liquids[fluid_types[k]] and (pressures[k] * pipeworks.liquids[fluid_types[k]].density * vector.dot(pipeworks.gravity, offsets[k]))) or 0 -- get gravitational bias + biases[k] = math.max(math.min(biases[k], pressures[k]), -pressures[k]) + if biases[k] then pressures[k] = pressures[k] - biases[k] end -- apply bias + if (not fluid_types[k]) or (pressures[k] < 0.001) or currentfluidtype == fluid_types[k] then + -- get same-type connections + migrate[#migrate + 1] = k + -- for each neighbour, add neighbour's pressure to the total to balance out + if currentfluidtype == fluid_types[k] then total_pressure = total_pressure + pressures[k] end + elseif pressures[k] > (2 * currentpressure) then -- check for high-pressure "intrusive" connections + intrusive[#intrusive + 1] = k + end + end + + if #migrate == 0 then return currentpressure, currentfluidtype end - -- for each neighbour, add neighbour's pressure to the total to balance out - for _, neighbour in ipairs(connections) do - local n = neighbour.get() - totalv = totalv + n - totalc = totalc + 1 + -- average values + local pressure_count = #migrate + 1 + local currentpressure = total_pressure / pressure_count + for k, migrated in ipairs(migrate) do + pressures[migrated] = currentpressure + currentfluidtype = currentfluidtype or fluid_types[migrated] + fluid_types[migrated] = currentfluidtype end - local average = totalv / totalc - for _, target in ipairs(connections) do - target.set(average) + + if #intrusive > 0 then + core.log("st") + -- take from most "intrusive" connection + local add = currentpressure / #migrate + if #intrusive == 1 then + local intruder = intrusive[1] + core.log(dump(intruder) .. ": " .. dump(pressures[intruder])) + core.log(dump(pressures)) + -- put current fluid in migration + for _, migrated in ipairs(migrate) do + pressures[migrated] = pressures[migrated] + add + end + core.log(pressures[intruder]) + -- overwritingly distribute intrusive + currentfluidtype = fluid_types[intruder] + currentpressure = (pressures[intruder] - biases[intruder]) * 0.5 + pressures[intruder] = currentpressure + biases[intruder] + core.log(pressures[intruder] + currentpressure) + else + -- find most "intrusive" connection + local highest_pressure = 0 + local most_intrusive + for _, intruder in ipairs(intrusive) do + if pressures[intruder] > highest_pressure then + most_intrusive = intruder + end + end + -- put current fluid in migration + for _, migrated in ipairs(migrate) do + pressures[migrated] = pressures[migrated] + add + end + -- overwritingly distribute intrusive + currentfluidtype = fluid_types[most_intrusive] + currentpressure = (pressures[most_intrusive] - biases[most_intrusive]) * 0.5 + pressures[most_intrusive] = currentpressure + biases[most_intrusive] + end + end + + -- unapply biases + for k, bias in pairs(biases) do + pressures[k] = pressures[k] + bias end - return average + -- set pressures and types + for k, pressure in ipairs(pressures) do + connections[k].set(pressure) + tconnections[k].set(fluid_types[k]) + end + + return currentpressure, currentfluidtype end -flowlogic.run_input = function(pos, node, currentpressure, inputdef) +flowlogic.run_input = function(pos, node, currentpressure, inputdef, currentfluidtype) -- intakefn allows a given input node to define it's own intake logic. - -- this function will calculate the maximum amount of water that can be taken in; + -- this function will calculate the maximum amount of fluid that can be taken in; -- the intakefn will be given this and is expected to return the actual absorption amount. local maxpressure = inputdef.maxpressure local intake_limit = maxpressure - currentpressure - if intake_limit <= 0 then return currentpressure end + if intake_limit <= 0 then return currentpressure, currentfluidtype end - local actual_intake = inputdef.intakefn(pos, intake_limit) + local actual_intake, newtype = inputdef.intakefn(pos, intake_limit, currentfluidtype) --pipeworks.logger("run_input@"..formatvec(pos).." oldpressure "..currentpressure.." intake_limit "..intake_limit.." actual_intake "..actual_intake) - if actual_intake <= 0 then return currentpressure end + if actual_intake <= 0 then return currentpressure, newtype end local newpressure = actual_intake + currentpressure --debuglog("run_input() end, oldpressure "..currentpressure.." intake_limit "..intake_limit.." actual_intake "..actual_intake.." newpressure "..newpressure) - return newpressure + return newpressure, newtype end -- flowlogic output helper implementation: --- outputs water by trying to place water nodes nearby in the world. --- neighbours is a list of node offsets to try placing water in. +-- outputs fluid by trying to place fluid nodes nearby in the world. +-- neighbours is a list of node offsets to try placing fluid in. -- this is a constructor function, returning another function which satisfies the output helper requirements. -- note that this does *not* take rotation into account. flowlogic.helpers.make_neighbour_output_fixed = function(neighbours) - return function(pos, node, currentpressure, finitemode) + return function(pos, node, currentpressure, finitemode, currentfluidtype) + if not currentfluidtype then return 0, currentfluidtype end + local finitemode = finitemode or finites[currentfluidtype] local taken = 0 for _, offset in pairs(neighbours) do local npos = vector.add(pos, offset) local name = minetest.get_node(npos).name if currentpressure < 1 then break end - -- take pressure anyway in non-finite mode, even if node is water source already. + -- take pressure anyway in non-finite mode, even if node is fluid source already. -- 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; + -- so in non-finite mode, placing fluid is dependent on the target node; -- draining pressure is not. - local canplace = (name == "air") or (name == pipeworks.liquids.water.flowing) + local canplace = (name == "air") or (core.registered_nodes[name] == core.registered_nodes[name].liquid_alternative_flowing) if canplace then - minetest.swap_node(npos, {name=pipeworks.liquids.water.source}) + minetest.swap_node(npos, {name=pipeworks.liquids[currentfluidtype].source}) end if (not finitemode) or canplace then taken = taken + 1 currentpressure = currentpressure - 1 end end - return taken + return taken, currentfluidtype end end -- complementary function to the above when using non-finite mode: --- removes water sources from neighbor positions when the output is "off" due to lack of pressure. +-- removes fluid sources from neighbor positions when the output is "off" due to lack of pressure. flowlogic.helpers.make_neighbour_cleanup_fixed = function(neighbours) return function(pos, node, currentpressure) --pipeworks.logger("neighbour_cleanup_fixed@"..formatvec(pos)) for _, offset in pairs(neighbours) do local npos = vector.add(pos, offset) local name = minetest.get_node(npos).name - if (name == pipeworks.liquids.water.source) then + if (core.registered_nodes[name] == core.registered_nodes[name].liquid_alternative_source) then --pipeworks.logger("neighbour_cleanup_fixed removing "..formatvec(npos)) minetest.remove_node(npos) end @@ -278,35 +392,36 @@ end -flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputdef, finitemode) - -- processing step for water output devices. +flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputdef, finitemode, currentfluidtype) + -- processing step for fluid output devices. -- takes care of checking a minimum pressure value and updating the resulting pressure level -- the outputfn is provided the current pressure and returns the pressure "taken". -- as an example, using this with the above spigot function, - -- the spigot function tries to output a water source if it will fit in the world. + -- the spigot function tries to output a fluid source if it will fit in the world. --pipeworks.logger("flowlogic.run_output() pos "..formatvec(pos).." old -> currentpressure "..tostring(oldpressure).." "..tostring(currentpressure).." finitemode "..tostring(finitemode)) + local finitemode = finitemode or finites[currentfluidtype] local upper = outputdef.upper local lower = outputdef.lower local result = currentpressure local threshold if finitemode then threshold = lower else threshold = upper end if currentpressure > threshold then - local takenpressure = outputdef.outputfn(pos, node, currentpressure, finitemode) + local takenpressure, currentfluidtype = outputdef.outputfn(pos, node, currentpressure, finitemode, currentfluidtype) local newpressure = currentpressure - takenpressure if newpressure < 0 then newpressure = 0 end result = newpressure end if (not finitemode) and (currentpressure < lower) and (oldpressure < lower) then --pipeworks.logger("flowlogic.run_output() invoking cleanup currentpressure="..tostring(currentpressure)) - outputdef.cleanupfn(pos, node, currentpressure) + outputdef.cleanupfn(pos, node, currentpressure, currentfluidtype) end - return result + return result, currentfluidtype end -- determine which node to switch to based on current pressure -flowlogic.run_transition = function(node, currentpressure) +flowlogic.run_transition = function(node, currentpressure, currentfluidtype) --WISHME: maybe use fluid type in transitions local simplesetdef = pipeworks.flowables.transitions.simple[node.name] local result = node local found = false From 253e1effce871fb10c4e09cbe56d0ebbdd90f6ba Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:47:54 -0500 Subject: [PATCH 36/54] fix, bad copy --- flowing_logic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flowing_logic.lua b/flowing_logic.lua index 608238cd..46132d63 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 core.registered_nodes[name].liquid_alternative_flowing) then + if belowname and (belowname == "air" or core.registered_nodes[belowname].liquid_alternative_flowing) then local spigotname = minetest.get_node(pos).name local fdir=node.param2 % 4 local check = { From 5333b2e0b886db95bb8a56dcb488c24cc7882eee Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:49:58 -0500 Subject: [PATCH 37/54] fix allowing fluid outs to change stored type for some reason --- pressure_logic/abms.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pressure_logic/abms.lua b/pressure_logic/abms.lua index 547c38d2..2ec3b6df 100644 --- a/pressure_logic/abms.lua +++ b/pressure_logic/abms.lua @@ -57,7 +57,7 @@ local check_for_liquids_v2 = function(pos, limit, current_type) end end --pipeworks.logger("check_for_liquids_v2@"..formatvec(pos).." total "..total) - + return total, fluid_type end flowlogic.check_for_liquids_v2 = check_for_liquids_v2 @@ -222,7 +222,7 @@ flowlogic.balance_pressure = function(pos, node, currentpressure, currentfluidty -- unconditionally include self in nodes to average over. -- result of averaging will be returned as new pressure for main flow logic callback - + -- pressure handles to average over local connections, tconnections, offsets = get_neighbour_positions(pos, node) @@ -404,9 +404,11 @@ flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputd local lower = outputdef.lower local result = currentpressure local threshold + local currentfluidtype if finitemode then threshold = lower else threshold = upper end if currentpressure > threshold then - local takenpressure, currentfluidtype = outputdef.outputfn(pos, node, currentpressure, finitemode, currentfluidtype) + local takenpressure + takenpressure, currentfluidtype = outputdef.outputfn(pos, node, currentpressure, finitemode, currentfluidtype) local newpressure = currentpressure - takenpressure if newpressure < 0 then newpressure = 0 end result = newpressure From 254386623658b54bd4f5ac380d97260d4fe27de6 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:51:30 -0500 Subject: [PATCH 38/54] last commit summary was a bit vague --- pressure_logic/abms.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/pressure_logic/abms.lua b/pressure_logic/abms.lua index 2ec3b6df..cfc422e4 100644 --- a/pressure_logic/abms.lua +++ b/pressure_logic/abms.lua @@ -404,7 +404,6 @@ flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputd local lower = outputdef.lower local result = currentpressure local threshold - local currentfluidtype if finitemode then threshold = lower else threshold = upper end if currentpressure > threshold then local takenpressure From 4989f966ccc25728a875457c7b1f2da9264c39a1 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 15:41:01 -0500 Subject: [PATCH 39/54] Update pressure_logic.txt --- todo/pressure_logic.txt | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/todo/pressure_logic.txt b/todo/pressure_logic.txt index 60884e1d..88000e0d 100644 --- a/todo/pressure_logic.txt +++ b/todo/pressure_logic.txt @@ -17,17 +17,5 @@ VanessaE would like this to function as an output with the following properties: * When turning off in non-finite mode, for all neighbour nodes, replace the water sources with flowing water as discussed above, but *only* if those neighbouring sources do not have any water source neighbours of their own in turn - this will prevent the block from creating a "hole" in a uniform pool of water sources. - --- Support for other fluids in pipes (Feature request/wish list) -Various sources from IRC and github issues have indicated that the ability to carry amounts of substance other than water through pipes would see uses appear for it if it were implemented (there does not appear to be anything trying to do so right now). -Extending the pressure mechanism to handle new fluids would be simple enough, it would just have to deal with more variables. -However, this feature raises the question of how to handle mixtures of fluids in pipes. - -Two possible solutions appear evident: -+ Don't mix at all. For each flowable registered, either a variant would be created for each supported liquid, or each node would declare which fluid it carries explicitly. Flowable nodes for different fluids would not interact with each other at all. - -+ Equalise "pressure" of multiple fluid variables in a similar manner to how the single water pressure value is currently balanced out, however this raises the issue of how to deal with mixtures - for instance, how is a spigot to function with a mixed liquid? does it simply refuse to function if it doesn't know how to deal with a certain mixture (as it can only output whole nodes)? likewise for certain mixtures in pipes, should it be allowed for lava and water for instance to mix like they don't interact at all? - -This mechanism also hints at a weakness of the pressure logic mechanism as it currently stands - namely that liquids are handled like gases and assumed to be compressible. - +-- Make liquids incompressible From 161f3671259be8ea80856e961ca23ac6dff2da21 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 28 Apr 2025 15:42:32 -0500 Subject: [PATCH 40/54] did that not fix? hmm --- autocrafter.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 269d154e..5ec63e47 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -14,14 +14,14 @@ if core.get_modpath("unified_inventory") then groups = {not_in_creative_inventory = 1}, stack_max = 1, }) - + unified_inventory.register_craft_type("fluidshaped", { description = S("Shaped Fluid Craft"), icon = "pipeworks_autocrafter.png", width = 3, height = 4, }) - + unified_inventory.register_on_craft_registered( function (item_name, options) if options.type ~= "fluidshaped" then return end @@ -178,7 +178,6 @@ local function get_matching_craft(output_name, example_recipe, fluid_input) end end - return best_index and recipes[best_index].items or example_recipe end @@ -191,7 +190,7 @@ local function get_craft(pos, inventory, hash) local output, decremented_input = minetest.get_craft_result({ method = "normal", width = 3, items = example_recipe }) - + local fluid if (not output) or output.item:is_empty() then output, decremented_input, fluid = pipeworks.fluid_recipes:get({ From bc4a489f0a9f07f84377e3ebcec290ee91a98f64 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Tue, 29 Apr 2025 11:49:03 -0500 Subject: [PATCH 41/54] oops, forgot to remove that logger --- autocrafter.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/autocrafter.lua b/autocrafter.lua index 5ec63e47..09816114 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -203,7 +203,6 @@ local function get_craft(pos, inventory, hash) recipe = get_matching_craft(output.item:get_name(), example_recipe, fluid) end - core.log(dump(decremented_input)) craft = { fluid = fluid, recipe = recipe, From c21f4bec429d4d3c205523b2cb02f510e63dc39b Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Tue, 29 Apr 2025 11:49:38 -0500 Subject: [PATCH 42/54] oops, forgot to remove that logger --- pressure_logic/abms.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pressure_logic/abms.lua b/pressure_logic/abms.lua index cfc422e4..ee7d6bc2 100644 --- a/pressure_logic/abms.lua +++ b/pressure_logic/abms.lua @@ -270,23 +270,18 @@ flowlogic.balance_pressure = function(pos, node, currentpressure, currentfluidty end if #intrusive > 0 then - core.log("st") -- take from most "intrusive" connection local add = currentpressure / #migrate if #intrusive == 1 then local intruder = intrusive[1] - core.log(dump(intruder) .. ": " .. dump(pressures[intruder])) - core.log(dump(pressures)) -- put current fluid in migration for _, migrated in ipairs(migrate) do pressures[migrated] = pressures[migrated] + add end - core.log(pressures[intruder]) -- overwritingly distribute intrusive currentfluidtype = fluid_types[intruder] currentpressure = (pressures[intruder] - biases[intruder]) * 0.5 pressures[intruder] = currentpressure + biases[intruder] - core.log(pressures[intruder] + currentpressure) else -- find most "intrusive" connection local highest_pressure = 0 From 8cc9465829d7f8081f09c5e2372a9c40f7e85634 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Wed, 30 Apr 2025 04:56:55 -0500 Subject: [PATCH 43/54] multifluid source --- devices.lua | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/devices.lua b/devices.lua index 2f788d5c..f4636ae8 100644 --- a/devices.lua +++ b/devices.lua @@ -127,12 +127,10 @@ local pipes_devicelist = { -- Now define the nodes. -local sourcename = "pipeworks:source_loaded" -local tile = table.copy(core.registered_nodes[pipeworks.liquids.water.source].tiles[1]) -tile.name = tile.name .. "^pipeworks_source_frame.png" +local sourcename = "pipeworks:source" core.register_node(sourcename, { - description = S("Infinite Water Source"), - tiles = { tile }, + description = S("Infinite Fluid Source"), + tiles = { "pipeworks_source_frame.png" }, paramtype = "light", groups = {snappy=3, pipe=1, dig_generic = 4, axey=1, handy=1, pickaxey=1}, is_ground_content = false, @@ -141,7 +139,31 @@ core.register_node(sourcename, { key = "node_sound_metal_defaults", }, walkable = true, - pipe_connections = { top = 1, bottom = 1, front = 1, back = 1, left = 1, right = 1}, + pipe_connections = { top = 1, bottom = 1, front = 1, back = 1, left = 1, right = 1 }, + on_receive_fields = function(pos, _, fields, sender) + local playername = sender:get_player_name() + if core.is_protected(pos, playername) then + core.record_protection_violation(pos, playername) + core.chat_send_player(playername, S("Changes not saved, node protected!")) + return + end + if not core.is_creative_enabled(playername) then + core.chat_send_player(playername, S("Changes not saved, \"creative\" priv missing!")) + return + end + local meta = core.get_meta(pos) + meta:set_string("fluidamount",fields.pressure or meta:get_string("fluidamount")) + meta:set_string("fluidtype",(pipeworks.liquids[fields.fluidtype] and fields.fluidtype) or meta:get_string("fluidtype")) + end, + on_construct = function(pos) + local meta = core.get_meta(pos) + local fs = + "formspec_version[4]".. + "size[4.75,1.5]".. + "field[0.25,0.5;2.5,0.75;fluidtype;"..S("Fluid Type")..";${fluidtype}]".. + "field[3,0.5;1.5,0.75;pressure;"..S("Pressure")..";${fluidamount}]" + meta:set_string("formspec",fs) + end, after_place_node = function(pos) pipeworks.scan_for_pipe_objects(pos) end, @@ -151,7 +173,10 @@ core.register_node(sourcename, { }) new_flow_logic_register.simple(sourcename) -new_flow_logic_register.intake(sourcename, 4, function() return 4, "water" end) +new_flow_logic_register.intake(sourcename, math.huge, function(pos) + local meta = core.get_meta(pos) + return meta:get_float("fluidamount") - meta:get_float("pipeworks.pressure"), meta:get("fluidtype") +end) local states = { "on", "off" } From 60fe317b94315dea53c32368c453c58c1c2b9f95 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Wed, 30 Apr 2025 05:02:37 -0500 Subject: [PATCH 44/54] check for definitions 1st --- init.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 6f0a69fb..a3727fe5 100644 --- a/init.lua +++ b/init.lua @@ -12,6 +12,7 @@ pipeworks = { modpath = minetest.get_modpath("pipeworks"), register_fluid = function(self, alias, name, density, description) local def = core.registered_nodes[alias] + if not def then return false end self.liquids[name] = { def = def, source = def.liquid_alternative_source, @@ -20,10 +21,11 @@ pipeworks = { density = density, -- in g/cm³ as standard } self.fluid_types[def.liquid_alternative_source] = name + return true end, liquids = {}, fluid_types = {}, -- easier indexing - gravity = {x=0, y=-0.025, z=0}, -- pressure bias factor, SI unit unspecified + gravity = {x=0, y=-0.025, z=0}, -- pressure bias factor, unit unspecified } -- fluid registration From 0e6ff9e0fa4794708752d88dbd9cf4d0c1d61b96 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Wed, 30 Apr 2025 05:05:27 -0500 Subject: [PATCH 45/54] shut luacheck up --- devices.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devices.lua b/devices.lua index f4636ae8..1f7c5a97 100644 --- a/devices.lua +++ b/devices.lua @@ -157,7 +157,7 @@ core.register_node(sourcename, { end, on_construct = function(pos) local meta = core.get_meta(pos) - local fs = + local fs = "formspec_version[4]".. "size[4.75,1.5]".. "field[0.25,0.5;2.5,0.75;fluidtype;"..S("Fluid Type")..";${fluidtype}]".. From 4d8c9c3dd6d016142af7e8682a95b7e195bb7f40 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Wed, 7 May 2025 01:54:41 -0500 Subject: [PATCH 46/54] stop with the manually constructed vector --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index a3727fe5..829f90a9 100644 --- a/init.lua +++ b/init.lua @@ -25,7 +25,7 @@ pipeworks = { end, liquids = {}, fluid_types = {}, -- easier indexing - gravity = {x=0, y=-0.025, z=0}, -- pressure bias factor, unit unspecified + gravity = vector.new(0, -0.025, 0), -- pressure bias factor, unit unspecified } -- fluid registration From e2c0d3fedc8df322ef65944d91f68639cfb7a6c2 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Wed, 7 May 2025 01:57:32 -0500 Subject: [PATCH 47/54] shut luacheck up --- autocrafter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autocrafter.lua b/autocrafter.lua index 09816114..c7525b7c 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -2,7 +2,7 @@ local S = minetest.get_translator("pipeworks") if core.get_modpath("unified_inventory") then core.register_craftitem("pipeworks:text_req", { - description = S("Requirements"), + description = S("Requirements"), inventory_image = "text_req.png", groups = {not_in_creative_inventory = 1}, stack_max = 1, From 22e45228f68414c8c9c844bb6e9eb89b3edb3be3 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:16:01 -0500 Subject: [PATCH 48/54] fix crash --- autocrafter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autocrafter.lua b/autocrafter.lua index c7525b7c..cdb41397 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -354,7 +354,7 @@ local function autocraft(inventory, craft, fluid) -- check if we have enough material available local inv_index = count_index(inventory:get_list("src")) local consumption = calculate_consumption(inv_index, craft.consumption) - if craftfluid and ((not consumption) or check_fluid_insufficiency(craftfluid, fluid)) then + if (not consumption) or (craftfluid and check_fluid_insufficiency(craftfluid, fluid) then return false end From 42975f78bc46012bdb5c8d9aef903dbba12e8db8 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:17:05 -0500 Subject: [PATCH 49/54] forgot a paren --- autocrafter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autocrafter.lua b/autocrafter.lua index cdb41397..49f3f1ee 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -354,7 +354,7 @@ local function autocraft(inventory, craft, fluid) -- check if we have enough material available local inv_index = count_index(inventory:get_list("src")) local consumption = calculate_consumption(inv_index, craft.consumption) - if (not consumption) or (craftfluid and check_fluid_insufficiency(craftfluid, fluid) then + if (not consumption) or (craftfluid and check_fluid_insufficiency(craftfluid, fluid)) then return false end From fc00172700ff7a2511bf7a70e900907af75a2d88 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Tue, 30 Dec 2025 09:55:00 -0500 Subject: [PATCH 50/54] readability --- common.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common.lua b/common.lua index 7d7a1d67..944403de 100644 --- a/common.lua +++ b/common.lua @@ -220,7 +220,7 @@ function fs_helpers.get_inv(y,x) local inv_y = (y + 0.4) or 6.9 local size, spacing = 1, 0.1 local hotbar_len = i3.settings.hotbar_len or (i3.settings.legacy_inventory and 8 or 9) - local hotbar_width = (i3.settings.inv_size and (i3.settings.inv_size/hotbar_len)) or 4 + local hotbar_width = i3.settings.inv_size and (i3.settings.inv_size / hotbar_len) or 4 --local inv_size = i3.settings.inv_size or (hotbar_len * hotbar_width) is useless table.insert(fs, "style_type[box;colors=#77777710,#77777710,#777,#777]") @@ -235,7 +235,7 @@ function fs_helpers.get_inv(y,x) table.insert(fs, "style_type[box;colors=#666]") for i=0, 2 do for j=0, hotbar_len - 1 do - table.insert(fs, "box["..inv_x+(j*(spacing+size))..","..(inv_y+size+spacing+0.05)+(i*(spacing+size))..";"..size..","..size..";]") + table.insert(fs, "box["..(inv_x + j * (spacing + size))..","..(inv_y + size + spacing + 0.05) + (i * (spacing + size))..";"..size..","..size..";]") end end @@ -260,7 +260,7 @@ function fs_helpers.get_inv(y,x) table.insert(fs, "style_type[box;colors=#666]") for i=0, 2 do for j=0, hotbar_len - 1 do - table.insert(fs, "box["..inv_x+(j*(spacing+size))..","..(inv_y+size+spacing+0.05)+(i*(spacing+size))..";"..size..","..size..";]") + table.insert(fs, "box["..(inv_x + j * (spacing + size))..","..(inv_y + size + spacing + 0.05) + (i * (spacing + size))..";"..size..","..size..";]") end end From 4a6a0f39b5b6762ba746c08b9d1fc8bfdb735306 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Tue, 30 Dec 2025 10:00:17 -0500 Subject: [PATCH 51/54] xcompat where possible oddly enough, xcompat doesn't do anything with riverwater and lava --- crafts.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crafts.lua b/crafts.lua index 293dfb1d..1753f134 100644 --- a/crafts.lua +++ b/crafts.lua @@ -320,14 +320,12 @@ end if pipeworks.enable_autocrafter then local buckets = {} +buckets.air = materials.empty_bucket +buckets.water = materials.water_bucket if core.get_modpath("bucket") then - buckets.air = "bucket:bucket_empty" - buckets.water = "bucket:bucket_water" buckets.river_water = "bucket:bucket_river_water" buckets.lava = "bucket:bucket_lava" elseif core.get_modpath("mcl_buckets") then - buckets.air = "mcl_buckets:bucket_empty" - buckets.water = "mcl_buckets:bucket_water" buckets.river_water = "mcl_buckets:bucket_river_water" buckets.lava = "mcl_buckets:bucket_lava" end From c254776b390cdd61e44f707311d0c5ddf30070db Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Tue, 30 Dec 2025 10:14:38 -0500 Subject: [PATCH 52/54] announce deprecation "Deprecate flowing_logic.lua for classic flow logic Mark the file as deprecated due to new flow logic requirements." - copilot --- flowing_logic.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flowing_logic.lua b/flowing_logic.lua index 92effcef..eaad6489 100644 --- a/flowing_logic.lua +++ b/flowing_logic.lua @@ -1,3 +1,5 @@ +-- This file is entirely deprecated, as new behavior requires "pressure" flow logic while this file is only ever used in "classic" flow logic. + -- This file provides the actual flow and pathfinding logic that makes water -- move through the pipes. -- From 48903745d4af5c10e4e0e6df56222aa19c22a67d Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Tue, 30 Dec 2025 10:17:09 -0500 Subject: [PATCH 53/54] reduce loading baggage --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index bf6ae3ee..66e29aa9 100644 --- a/init.lua +++ b/init.lua @@ -81,7 +81,7 @@ dofile(pipeworks.modpath.."/autoplace_pipes.lua") dofile(pipeworks.modpath.."/autoplace_tubes.lua") dofile(pipeworks.modpath.."/luaentity.lua") dofile(pipeworks.modpath.."/item_transport.lua") -dofile(pipeworks.modpath.."/flowing_logic.lua") +if pipeworks.toggles.pipe_mode == "classic" then dofile(pipeworks.modpath.."/flowing_logic.lua") end dofile(pipeworks.modpath.."/filter-injector.lua") dofile(pipeworks.modpath.."/chests.lua") dofile(pipeworks.modpath.."/trashcan.lua") From 86cf653a6e8dda5c2b7eecfd505721ff78b791e6 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Wed, 31 Dec 2025 06:32:42 -0500 Subject: [PATCH 54/54] fix styling --- init.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 66e29aa9..69571c43 100644 --- a/init.lua +++ b/init.lua @@ -81,7 +81,9 @@ dofile(pipeworks.modpath.."/autoplace_pipes.lua") dofile(pipeworks.modpath.."/autoplace_tubes.lua") dofile(pipeworks.modpath.."/luaentity.lua") dofile(pipeworks.modpath.."/item_transport.lua") -if pipeworks.toggles.pipe_mode == "classic" then dofile(pipeworks.modpath.."/flowing_logic.lua") end +if pipeworks.toggles.pipe_mode == "classic" then + dofile(pipeworks.modpath.."/flowing_logic.lua") +end dofile(pipeworks.modpath.."/filter-injector.lua") dofile(pipeworks.modpath.."/chests.lua") dofile(pipeworks.modpath.."/trashcan.lua")