Skip to content

Commit

Permalink
Added new melonlib function for great looking pipe connection graphics.
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotmelon committed Jan 19, 2025
1 parent a459980 commit 79ae9ea
Show file tree
Hide file tree
Showing 27 changed files with 292 additions and 166 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-east-frozen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 32,
height = 56,
shift = util.by_pixel( -20.5, 0.5),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-east-frozen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-east.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 32,
height = 56,
shift = util.by_pixel( -20.5, 0.5),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-east.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-north-frozen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 60,
height = 74,
shift = util.by_pixel( -1.0, 22.5),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-north-frozen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-north.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 60,
height = 74,
shift = util.by_pixel( -1.0, 22.5),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-north.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-shadow-east.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 68,
height = 32,
shift = util.by_pixel( -11.0, 41.0),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-shadow-east.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-shadow-north.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 70,
height = 68,
shift = util.by_pixel( 8.0, 40.5),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-shadow-north.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-shadow-south.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 66,
height = 38,
shift = util.by_pixel( 6.0, -15.5),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-shadow-south.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-shadow-west.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 68,
height = 36,
shift = util.by_pixel( 33.0, 8.5),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-shadow-west.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-south-frozen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 54,
height = 58,
shift = util.by_pixel( 0.5, -18.0),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-south-frozen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-south.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 54,
height = 58,
shift = util.by_pixel( 0.5, -18.0),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-south.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-west-frozen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 38,
height = 62,
shift = util.by_pixel( 22.5, 2.0),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-west-frozen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions graphics/pipe-connections/pipe-west.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return
{
width = 38,
height = 62,
shift = util.by_pixel( 22.5, 2.0),
line_length = 1,
}
Binary file added graphics/pipe-connections/pipe-west.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
167 changes: 1 addition & 166 deletions lib/data-stage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "metas.metas"
require "autorecipes"
require "pipe-connections"

---Returns a 1x1 empty image.
---@return table
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 79ae9ea

Please sign in to comment.