Skip to content

Commit

Permalink
Add startup setting for braided pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotmelon committed Oct 19, 2024
1 parent d32ba26 commit 63f495f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 57 deletions.
84 changes: 43 additions & 41 deletions data-final-fixes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,62 @@ for name, storage_tank in pairs(data.raw["storage-tank"]) do
end
end

-- the following bloc of code handles adding pipe connection_categories to all fluidboxes in the game.
-- this allows for underground pipe weaving with pyhightech and niobium pipes
for entity_prototype in pairs(defines.prototypes.entity) do
if entity_prototype == "pipe" or entity_prototype == "pipe-to-ground" then
goto continue
end
if settings.startup["py-braided-pipes"].value then
-- the following bloc of code handles adding pipe connection_categories to all fluidboxes in the game.
-- this allows for underground pipe weaving with pyhightech and niobium pipes
for entity_prototype in pairs(defines.prototypes.entity) do
if entity_prototype == "pipe" or entity_prototype == "pipe-to-ground" then
goto continue
end

for _, entity in pairs(data.raw[entity_prototype] or {}) do
local fluid_boxes = entity.fluid_boxes or {}
for _, entity in pairs(data.raw[entity_prototype] or {}) do
local fluid_boxes = entity.fluid_boxes or {}

if entity.fluid_box then
fluid_boxes[#fluid_boxes + 1] = entity.fluid_box
end
if entity.fluid_box then
fluid_boxes[#fluid_boxes + 1] = entity.fluid_box
end

if entity.input_fluid_box then
fluid_boxes[#fluid_boxes + 1] = entity.input_fluid_box
end
if entity.input_fluid_box then
fluid_boxes[#fluid_boxes + 1] = entity.input_fluid_box
end

if entity.output_fluid_box then
fluid_boxes[#fluid_boxes + 1] = entity.output_fluid_box
end
if entity.output_fluid_box then
fluid_boxes[#fluid_boxes + 1] = entity.output_fluid_box
end

if entity.fuel_fluid_box then
fluid_boxes[#fluid_boxes + 1] = entity.fuel_fluid_box
end
if entity.fuel_fluid_box then
fluid_boxes[#fluid_boxes + 1] = entity.fuel_fluid_box
end

if entity.oxidizer_fluid_box then
fluid_boxes[#fluid_boxes + 1] = entity.oxidizer_fluid_box
end
if entity.oxidizer_fluid_box then
fluid_boxes[#fluid_boxes + 1] = entity.oxidizer_fluid_box
end

for _, fluid_box in pairs(fluid_boxes) do
if type(fluid_box) == "table" then
for _, pipe_connection in pairs(fluid_box.pipe_connections or {}) do
local connection_category = pipe_connection.connection_category
if connection_category == nil then
connection_category = {"default"}
elseif type(connection_category) == "string" then
connection_category = {connection_category}
end
for _, fluid_box in pairs(fluid_boxes) do
if type(fluid_box) == "table" then
for _, pipe_connection in pairs(fluid_box.pipe_connections or {}) do
local connection_category = pipe_connection.connection_category
if connection_category == nil then
connection_category = {"default"}
elseif type(connection_category) == "string" then
connection_category = {connection_category}
end

connection_category[#connection_category + 1] = "pipe"
connection_category[#connection_category + 1] = "niobium-pipe"
connection_category[#connection_category + 1] = "ht-pipes" -- no need to check if pyhightech is installed
connection_category[#connection_category + 1] = "pipe"
connection_category[#connection_category + 1] = "niobium-pipe"
connection_category[#connection_category + 1] = "ht-pipes" -- no need to check if pyhightech is installed

pipe_connection.connection_category = connection_category
pipe_connection.connection_category = connection_category
end
end
end
end
::continue::
end
::continue::
end

for _, pipe in pairs{data.raw.pipe.pipe, data.raw["pipe-to-ground"]["pipe-to-ground"]} do
for _, pipe_connection in pairs(pipe.fluid_box.pipe_connections) do
pipe_connection.connection_category = {"pipe"}
for _, pipe in pairs{data.raw.pipe.pipe, data.raw["pipe-to-ground"]["pipe-to-ground"]} do
for _, pipe_connection in pairs(pipe.fluid_box.pipe_connections) do
pipe_connection.connection_category = {"pipe"}
end
end
end
2 changes: 2 additions & 0 deletions locale/en/locale.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,11 @@ poorman-wood-fence=Poor man's wooden fence
[mod-setting-name]
py-tank-adjust=Adjust Pymods' storage tanks capacity
py-braided-pipes=Enable braided pipes

[mod-setting-description]
py-tank-adjust=Makes tank capacity consistent with their physical size
py-braided-pipes=This setting makes vanilla pipes, niobium pipes, and multipurpose pipes not connect with each other. It also makes their underground versions not connect with each other, allowing for underground pipe braiding.

[recipe-name]
py-void=Void __1__
Expand Down
14 changes: 8 additions & 6 deletions prototypes/pipes/niobium-pipes.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local NIOBIUM_CONNECTION_CATEGORY = settings.startup["py-braided-pipes"].value and {"niobium-pipe"} or nil

--- @param i integer
local function make_visualization(i)
return
Expand Down Expand Up @@ -371,22 +373,22 @@ ENTITY {
{
position = {0, -0},
direction = defines.direction.north,
connection_category = {"niobium-pipe"}
connection_category = NIOBIUM_CONNECTION_CATEGORY
},
{
position = {0, 0},
direction = defines.direction.east,
connection_category = {"niobium-pipe"}
connection_category = NIOBIUM_CONNECTION_CATEGORY
},
{
position = {0, 0},
direction = defines.direction.south,
connection_category = {"niobium-pipe"}
connection_category = NIOBIUM_CONNECTION_CATEGORY
},
{
position = {-0, 0},
direction = defines.direction.west,
connection_category = {"niobium-pipe"}
connection_category = NIOBIUM_CONNECTION_CATEGORY
}
},
hide_connection_info = true,
Expand Down Expand Up @@ -432,14 +434,14 @@ ENTITY {
{
position = {0, -0},
direction = defines.direction.north,
connection_category = {"niobium-pipe"}
connection_category = NIOBIUM_CONNECTION_CATEGORY
},
{
position = {0, 0},
direction = defines.direction.south,
connection_type = "underground",
max_underground_distance = 32,
connection_category = {"niobium-pipe"}
connection_category = NIOBIUM_CONNECTION_CATEGORY
}
},
hide_connection_info = true,
Expand Down
25 changes: 15 additions & 10 deletions settings.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
data:extend
{
{
type = "bool-setting",
name = "py-tank-adjust",
setting_type = "startup",
default_value = false,
order = "e",
},
}
data:extend {{
type = "bool-setting",
name = "py-tank-adjust",
setting_type = "startup",
default_value = false,
order = "e",
}}

data:extend {{
type = "bool-setting",
name = "py-braided-pipes",
setting_type = "startup",
default_value = true,
order = "f",
}}

0 comments on commit 63f495f

Please sign in to comment.