diff --git a/changelog.txt b/changelog.txt index fb8154e..78e94a5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ Date: ? Changes: - Fixed multiple melonlib functions still check for .expensive and .normal. Resolves https://github.com/pyanodon/pybugreports/issues/773 - Added compatibility with the compaktcircuit mod. + - Added new melonlib function for great looking pipe connection graphics. --------------------------------------------------------------------------------------------------- Version: 3.0.21 Date: 2025-1-2 diff --git a/graphics/pipe-connections/pipe-east-frozen.lua b/graphics/pipe-connections/pipe-east-frozen.lua new file mode 100644 index 0000000..39bfb2b --- /dev/null +++ b/graphics/pipe-connections/pipe-east-frozen.lua @@ -0,0 +1,7 @@ +return +{ + width = 32, + height = 56, + shift = util.by_pixel( -20.5, 0.5), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-east-frozen.png b/graphics/pipe-connections/pipe-east-frozen.png new file mode 100644 index 0000000..24e6559 Binary files /dev/null and b/graphics/pipe-connections/pipe-east-frozen.png differ diff --git a/graphics/pipe-connections/pipe-east.lua b/graphics/pipe-connections/pipe-east.lua new file mode 100644 index 0000000..39bfb2b --- /dev/null +++ b/graphics/pipe-connections/pipe-east.lua @@ -0,0 +1,7 @@ +return +{ + width = 32, + height = 56, + shift = util.by_pixel( -20.5, 0.5), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-east.png b/graphics/pipe-connections/pipe-east.png new file mode 100644 index 0000000..4bdb40e Binary files /dev/null and b/graphics/pipe-connections/pipe-east.png differ diff --git a/graphics/pipe-connections/pipe-north-frozen.lua b/graphics/pipe-connections/pipe-north-frozen.lua new file mode 100644 index 0000000..7d3423f --- /dev/null +++ b/graphics/pipe-connections/pipe-north-frozen.lua @@ -0,0 +1,7 @@ +return +{ + width = 60, + height = 74, + shift = util.by_pixel( -1.0, 22.5), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-north-frozen.png b/graphics/pipe-connections/pipe-north-frozen.png new file mode 100644 index 0000000..5b3010b Binary files /dev/null and b/graphics/pipe-connections/pipe-north-frozen.png differ diff --git a/graphics/pipe-connections/pipe-north.lua b/graphics/pipe-connections/pipe-north.lua new file mode 100644 index 0000000..7d3423f --- /dev/null +++ b/graphics/pipe-connections/pipe-north.lua @@ -0,0 +1,7 @@ +return +{ + width = 60, + height = 74, + shift = util.by_pixel( -1.0, 22.5), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-north.png b/graphics/pipe-connections/pipe-north.png new file mode 100644 index 0000000..d72528e Binary files /dev/null and b/graphics/pipe-connections/pipe-north.png differ diff --git a/graphics/pipe-connections/pipe-shadow-east.lua b/graphics/pipe-connections/pipe-shadow-east.lua new file mode 100644 index 0000000..946856a --- /dev/null +++ b/graphics/pipe-connections/pipe-shadow-east.lua @@ -0,0 +1,7 @@ +return +{ + width = 68, + height = 32, + shift = util.by_pixel( -11.0, 41.0), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-shadow-east.png b/graphics/pipe-connections/pipe-shadow-east.png new file mode 100644 index 0000000..576c4ad Binary files /dev/null and b/graphics/pipe-connections/pipe-shadow-east.png differ diff --git a/graphics/pipe-connections/pipe-shadow-north.lua b/graphics/pipe-connections/pipe-shadow-north.lua new file mode 100644 index 0000000..eabafa7 --- /dev/null +++ b/graphics/pipe-connections/pipe-shadow-north.lua @@ -0,0 +1,7 @@ +return +{ + width = 70, + height = 68, + shift = util.by_pixel( 8.0, 40.5), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-shadow-north.png b/graphics/pipe-connections/pipe-shadow-north.png new file mode 100644 index 0000000..f520c7d Binary files /dev/null and b/graphics/pipe-connections/pipe-shadow-north.png differ diff --git a/graphics/pipe-connections/pipe-shadow-south.lua b/graphics/pipe-connections/pipe-shadow-south.lua new file mode 100644 index 0000000..ce1a038 --- /dev/null +++ b/graphics/pipe-connections/pipe-shadow-south.lua @@ -0,0 +1,7 @@ +return +{ + width = 66, + height = 38, + shift = util.by_pixel( 6.0, -15.5), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-shadow-south.png b/graphics/pipe-connections/pipe-shadow-south.png new file mode 100644 index 0000000..54b62cd Binary files /dev/null and b/graphics/pipe-connections/pipe-shadow-south.png differ diff --git a/graphics/pipe-connections/pipe-shadow-west.lua b/graphics/pipe-connections/pipe-shadow-west.lua new file mode 100644 index 0000000..7159693 --- /dev/null +++ b/graphics/pipe-connections/pipe-shadow-west.lua @@ -0,0 +1,7 @@ +return +{ + width = 68, + height = 36, + shift = util.by_pixel( 33.0, 8.5), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-shadow-west.png b/graphics/pipe-connections/pipe-shadow-west.png new file mode 100644 index 0000000..1134915 Binary files /dev/null and b/graphics/pipe-connections/pipe-shadow-west.png differ diff --git a/graphics/pipe-connections/pipe-south-frozen.lua b/graphics/pipe-connections/pipe-south-frozen.lua new file mode 100644 index 0000000..ab5b0e9 --- /dev/null +++ b/graphics/pipe-connections/pipe-south-frozen.lua @@ -0,0 +1,7 @@ +return +{ + width = 54, + height = 58, + shift = util.by_pixel( 0.5, -18.0), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-south-frozen.png b/graphics/pipe-connections/pipe-south-frozen.png new file mode 100644 index 0000000..6c3572e Binary files /dev/null and b/graphics/pipe-connections/pipe-south-frozen.png differ diff --git a/graphics/pipe-connections/pipe-south.lua b/graphics/pipe-connections/pipe-south.lua new file mode 100644 index 0000000..ab5b0e9 --- /dev/null +++ b/graphics/pipe-connections/pipe-south.lua @@ -0,0 +1,7 @@ +return +{ + width = 54, + height = 58, + shift = util.by_pixel( 0.5, -18.0), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-south.png b/graphics/pipe-connections/pipe-south.png new file mode 100644 index 0000000..8973886 Binary files /dev/null and b/graphics/pipe-connections/pipe-south.png differ diff --git a/graphics/pipe-connections/pipe-west-frozen.lua b/graphics/pipe-connections/pipe-west-frozen.lua new file mode 100644 index 0000000..8209582 --- /dev/null +++ b/graphics/pipe-connections/pipe-west-frozen.lua @@ -0,0 +1,7 @@ +return +{ + width = 38, + height = 62, + shift = util.by_pixel( 22.5, 2.0), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-west-frozen.png b/graphics/pipe-connections/pipe-west-frozen.png new file mode 100644 index 0000000..b00676f Binary files /dev/null and b/graphics/pipe-connections/pipe-west-frozen.png differ diff --git a/graphics/pipe-connections/pipe-west.lua b/graphics/pipe-connections/pipe-west.lua new file mode 100644 index 0000000..8209582 --- /dev/null +++ b/graphics/pipe-connections/pipe-west.lua @@ -0,0 +1,7 @@ +return +{ + width = 38, + height = 62, + shift = util.by_pixel( 22.5, 2.0), + line_length = 1, +} diff --git a/graphics/pipe-connections/pipe-west.png b/graphics/pipe-connections/pipe-west.png new file mode 100644 index 0000000..8dcaaea Binary files /dev/null and b/graphics/pipe-connections/pipe-west.png differ diff --git a/lib/data-stage.lua b/lib/data-stage.lua index 4c8ca4e..ced2955 100644 --- a/lib/data-stage.lua +++ b/lib/data-stage.lua @@ -2,6 +2,7 @@ require "metas.metas" require "autorecipes" +require "pipe-connections" ---Returns a 1x1 empty image. ---@return table @@ -159,172 +160,6 @@ function py.composite_molten_icon(base_prototype, child_prototype, shadow_alpha) } end ----Define pipe connection pipe pictures, not all entities use these. ----@param pictures string ----@param shift_north table? ----@param shift_south table? ----@param shift_west table? ----@param shift_east table? ----@param replacements table? ----@return table -py.pipe_pictures = function(pictures, shift_north, shift_south, shift_west, shift_east, replacements) - local new_pictures = { - north = shift_north and - { - filename = "__base__/graphics/entity/" .. pictures .. "/" .. pictures .. "-pipe-N.png", - priority = "extra-high", - width = 71, - height = 38, - shift = shift_north, - scale = 0.5 - } or - py.empty_image(), - south = shift_south and - { - filename = "__base__/graphics/entity/" .. pictures .. "/" .. pictures .. "-pipe-S.png", - priority = "extra-high", - width = 88, - height = 61, - shift = shift_south, - scale = 0.5 - } or - py.empty_image(), - west = shift_west and - { - filename = "__base__/graphics/entity/" .. pictures .. "/" .. pictures .. "-pipe-W.png", - priority = "extra-high", - width = 39, - height = 73, - shift = shift_west, - scale = 0.5 - } or - py.empty_image(), - east = shift_east and - { - filename = "__base__/graphics/entity/" .. pictures .. "/" .. pictures .. "-pipe-E.png", - priority = "extra-high", - width = 42, - height = 76, - shift = shift_east, - scale = 0.5 - } or - py.empty_image() - } - for direction, image in pairs(replacements or {}) do - if new_pictures[direction].filename ~= "__core__/graphics/empty.png" then - new_pictures[direction].filename = image.filename - new_pictures[direction].width = image.width - new_pictures[direction].height = image.height - new_pictures[direction].priority = image.priority or new_pictures[direction].priority - new_pictures[direction].scale = 1 or new_pictures[direction].scale - end - end - return new_pictures -end - ----Define pipe connection pipe covers, not all entities use these. ----@param n boolean? ----@param s boolean? ----@param w boolean? ----@param e boolean? ----@return table -py.pipe_covers = function(n, s, w, e) - if (n == nil and s == nil and w == nil and e == nil) then - n, s, e, w = true, true, true, true - end - - n = - n and - { - layers = { - { - filename = "__base__/graphics/entity/pipe-covers/pipe-cover-north.png", - priority = "extra-high", - width = 128, - height = 128, - scale = 0.5 - }, - { - filename = "__base__/graphics/entity/pipe-covers/pipe-cover-north-shadow.png", - priority = "extra-high", - width = 128, - height = 128, - scale = 0.5, - draw_as_shadow = true - } - } - } or - py.empty_image() - e = - e and - { - layers = { - { - filename = "__base__/graphics/entity/pipe-covers/pipe-cover-east.png", - priority = "extra-high", - width = 128, - height = 128, - scale = 0.5 - }, - { - filename = "__base__/graphics/entity/pipe-covers/pipe-cover-east-shadow.png", - priority = "extra-high", - width = 128, - height = 128, - scale = 0.5, - draw_as_shadow = true - } - } - } or - py.empty_image() - s = - s and - { - layers = { - { - filename = "__base__/graphics/entity/pipe-covers/pipe-cover-south.png", - priority = "extra-high", - width = 128, - height = 128, - scale = 0.5 - }, - { - filename = "__base__/graphics/entity/pipe-covers/pipe-cover-south-shadow.png", - priority = "extra-high", - width = 128, - height = 128, - scale = 0.5, - draw_as_shadow = true - } - } - } or - py.empty_image() - w = - w and - { - layers = { - { - filename = "__base__/graphics/entity/pipe-covers/pipe-cover-west.png", - priority = "extra-high", - width = 128, - height = 128, - scale = 0.5 - }, - { - filename = "__base__/graphics/entity/pipe-covers/pipe-cover-west-shadow.png", - priority = "extra-high", - width = 128, - height = 128, - scale = 0.5, - draw_as_shadow = true - } - } - } or - py.empty_image() - - return {north = n, south = s, east = e, west = w} -end - ---Standardizes a product or ingredient prototype to a common format. ---@param p data.IngredientPrototype | data.ProductPrototype | string ---@return data.IngredientPrototype | data.ProductPrototype diff --git a/lib/pipe-connections.lua b/lib/pipe-connections.lua new file mode 100644 index 0000000..df24e13 --- /dev/null +++ b/lib/pipe-connections.lua @@ -0,0 +1,206 @@ +---Define pipe connection pipe pictures by coping from an existing entity in the base mod. +---@param pictures string +---@param shift_north table? +---@param shift_south table? +---@param shift_west table? +---@param shift_east table? +---@param replacements table? +---@return table +py.pipe_pictures = function(pictures, shift_north, shift_south, shift_west, shift_east, replacements) + local new_pictures = { + north = shift_north and + { + filename = "__base__/graphics/entity/" .. pictures .. "/" .. pictures .. "-pipe-N.png", + priority = "extra-high", + width = 71, + height = 38, + shift = shift_north, + scale = 0.5 + } or py.empty_image(), + south = shift_south and + { + filename = "__base__/graphics/entity/" .. pictures .. "/" .. pictures .. "-pipe-S.png", + priority = "extra-high", + width = 88, + height = 61, + shift = shift_south, + scale = 0.5 + } or py.empty_image(), + west = shift_west and + { + filename = "__base__/graphics/entity/" .. pictures .. "/" .. pictures .. "-pipe-W.png", + priority = "extra-high", + width = 39, + height = 73, + shift = shift_west, + scale = 0.5 + } or py.empty_image(), + east = shift_east and + { + filename = "__base__/graphics/entity/" .. pictures .. "/" .. pictures .. "-pipe-E.png", + priority = "extra-high", + width = 42, + height = 76, + shift = shift_east, + scale = 0.5 + } or py.empty_image() + } + for direction, image in pairs(replacements or {}) do + if new_pictures[direction].filename ~= "__core__/graphics/empty.png" then + new_pictures[direction].filename = image.filename + new_pictures[direction].width = image.width + new_pictures[direction].height = image.height + new_pictures[direction].priority = image.priority or new_pictures[direction].priority + new_pictures[direction].scale = 1 or new_pictures[direction].scale + end + end + return new_pictures +end + +---Define pipe connection pipe covers, not all entities use these. +---Example: https://github.com/pyanodon/pybugreports/issues/472 +---@param n boolean? +---@param s boolean? +---@param w boolean? +---@param e boolean? +---@return table +py.pipe_covers = function(n, s, w, e) + if (n == nil and s == nil and w == nil and e == nil) then + n, s, e, w = true, true, true, true + end + + n = + n and { + layers = { + { + filename = "__base__/graphics/entity/pipe-covers/pipe-cover-north.png", + priority = "extra-high", + width = 128, + height = 128, + scale = 0.5 + }, + { + filename = "__base__/graphics/entity/pipe-covers/pipe-cover-north-shadow.png", + priority = "extra-high", + width = 128, + height = 128, + scale = 0.5, + draw_as_shadow = true + } + } + } or py.empty_image() + e = + e and { + layers = { + { + filename = "__base__/graphics/entity/pipe-covers/pipe-cover-east.png", + priority = "extra-high", + width = 128, + height = 128, + scale = 0.5 + }, + { + filename = "__base__/graphics/entity/pipe-covers/pipe-cover-east-shadow.png", + priority = "extra-high", + width = 128, + height = 128, + scale = 0.5, + draw_as_shadow = true + } + } + } or py.empty_image() + s = + s and { + layers = { + { + filename = "__base__/graphics/entity/pipe-covers/pipe-cover-south.png", + priority = "extra-high", + width = 128, + height = 128, + scale = 0.5 + }, + { + filename = "__base__/graphics/entity/pipe-covers/pipe-cover-south-shadow.png", + priority = "extra-high", + width = 128, + height = 128, + scale = 0.5, + draw_as_shadow = true + } + } + } or py.empty_image() + w = + w and { + layers = { + { + filename = "__base__/graphics/entity/pipe-covers/pipe-cover-west.png", + priority = "extra-high", + width = 128, + height = 128, + scale = 0.5 + }, + { + filename = "__base__/graphics/entity/pipe-covers/pipe-cover-west-shadow.png", + priority = "extra-high", + width = 128, + height = 128, + scale = 0.5, + draw_as_shadow = true + } + } + } or py.empty_image() + + return {north = n, south = s, east = e, west = w} +end + +---Define nice looking pipe pictures based on the space age electromagnetic plant. +---These do not come with pipe covers! However there is a frozen variant. +---See seaweed-crop.lua in alien life for an example implementation. +py.sexy_pipe_pictures = function() + local function by_direction(pipe_direction) + return { + layers = { + util.sprite_load("__pypostprocessing__/graphics/pipe-connections/pipe-" .. pipe_direction, + { + scale = 0.5, + } + ), + util.sprite_load("__pypostprocessing__/graphics/pipe-connections/pipe-shadow-" .. pipe_direction, + { + scale = 0.5, + draw_as_shadow = true, + } + ) + } + } + end + + return { + north = by_direction("north"), + east = by_direction("east"), + south = by_direction("south"), + west = by_direction("west") + } +end + +---Define nice looking pipe frozen pictures based on the space age electromagnetic plant. +py.sexy_pipe_pictures_frozen = function() + local function by_direction(pipe_direction) + return { + layers = { + util.sprite_load("__pypostprocessing__/graphics/pipe-connections/pipe-" .. pipe_direction .. "-frozen", + { + scale = 0.5, + } + ) + } + } + end + + return { + north = by_direction("north"), + east = by_direction("east"), + south = by_direction("south"), + west = by_direction("west") + } +end