[Genhis] [1.1.48] mods - small bug in fill-barrel empty-barrel tint logic
Posted: Thu Dec 02, 2021 9:33 am
If a fluid has the base_color or flow_color property specified with indexed numbers e.g. { 151, 0, 147 }, the barrel is tinted with an alpha channel using a, which breaks the coloring.
Specifically, in base/data-updates.lua, line 59:
Causes black colors on the barrel, and an emission of a prototype warning if a mod uses the indexed numbers, e.g. :
This behavior is used in:
58: local function generate_barrel_item_icons(fluid, empty_barrel_item)
115: local function generate_fill_barrel_icons(fluid)
158: local function generate_empty_barrel_icons(fluid)
A small patch would work, though isn't 100% correct. If the logic above is replaced with:
Before:
After:
A "100%" accurate patch would test *all* of rgba before working in alphabet mode, and the wiki doesn't explicitly say if a nil indexed color is counted as 0 so there's a small omission of how to interpret indexed colors. (1-4? 1-nil? not really important, but for consideration)
Specifically, in base/data-updates.lua, line 59:
Code: Select all
local side_tint = util.table.deepcopy(fluid.base_color)
side_tint.a = side_alpha
local top_hoop_tint = util.table.deepcopy(fluid.flow_color)
top_hoop_tint.a = top_hoop_alpha
Code: Select all
22.741 Warning PrototypeLoader.cpp:205: Value ROOT.recipe.fill-DimensionalFluid-barrel.icons[1].tint.1 was not used.
22.741 Warning PrototypeLoader.cpp:205: Value ROOT.recipe.fill-DimensionalFluid-barrel.icons[1].tint.2 was not used.
22.741 Warning PrototypeLoader.cpp:205: Value ROOT.recipe.fill-DimensionalFluid-barrel.icons[1].tint.3 was not used.
58: local function generate_barrel_item_icons(fluid, empty_barrel_item)
115: local function generate_fill_barrel_icons(fluid)
158: local function generate_empty_barrel_icons(fluid)
A small patch would work, though isn't 100% correct. If the logic above is replaced with:
Code: Select all
local base_color = fluid.base_color
local side_tint = {
r = base_color.r or base_color[1],
g = base_color.g or base_color[2],
b = base_color.b or base_color[3],
a = side_alpha
}
local flow_color = fluid.flow_color
local top_hoop_tint = {
r = flow_color.r or flow_color[1],
g = flow_color.g or flow_color[2],
b = flow_color.b or flow_color[3],
a = top_hoop_alpha
}