Content
2 years ago
1.1 - 2.0
10.0K
Storage

g 2.1

4 months ago

Please 2.1🙏

a month ago

For those who wish to correct the mod themselves: set Info.jsn to 2.1, and in the Prototypes folder, replace the contents of the functions.lua script with this script.

if not wideChestsAaiReskin then wideChestsAaiReskin = {} end

local inputs = {
directory = "aai-containers",
yShift = -2,
scale = 0.5
}

function reskinWideChests(item, chestSize)
local singleWidth = 64
local firstGraphicsWidth = 96
local middleGraphicsWidth = 64
local lastGraphicsWidth = 96
local graphicsWidth = 128
local scale = 0.5;

if chestSize == 2 then
    width = graphicsWidth
else
    width = firstGraphicsWidth
end

local widthDifference = chestSize * singleWidth - width
local shift = -(widthDifference / 2) * inputs.scale
local endShift = singleWidth * (chestSize - 2) / 2 * inputs.scale

item.circuit_connector_sprites = nil

-- KORREKTUR FÜR FACTORIO 2.1: Wir nutzen die Definition der Standard-Stahlkiste als Basis
if circuit_connector_definitions and circuit_connector_definitions["steel-chest"] then
    item.circuit_connector = circuit_connector_definitions["steel-chest"]
else
    -- Fallback für den Notfall
    item.circuit_connector = {
        {
            points = {
                wire = {
                    green = util.by_pixel(endShift + 29, -11),
                    red = util.by_pixel(endShift + 29, -14),
                },
                shadow = {
                    green = util.by_pixel(endShift + 47, 4), 
                    red = util.by_pixel(endShift + 47, 1),
                }
            }
        }
    }
end

item.picture.layers = {
    {
        filename = inputs.directory.."/graphics/entity/dynamic/wide-chest.png",
        width = width, 
        height = 74, 
        scale = inputs.scale,
        shift = util.by_pixel(shift, inputs.yShift),
        priority = "extra-high",
    },
}

if chestSize > 2 then
    for i = 1, chestSize - 3 do
        table.insert(item.picture.layers, {
            filename = inputs.directory.."/graphics/entity/dynamic/wide-chest.png",
            width = 64, 
            height = 74, 
            x = 32,
            scale = inputs.scale,
            shift = util.by_pixel(shift + 8 + (middleGraphicsWidth * inputs.scale) * i, inputs.yShift),
            priority = "extra-high",
        })
    end
    table.insert(item.picture.layers, {
        filename = inputs.directory.."/graphics/entity/dynamic/wide-chest.png",
        width = lastGraphicsWidth, 
        height = 74, 
        x = 32,
        scale = inputs.scale,
        shift = util.by_pixel(shift + 48 + (middleGraphicsWidth * inputs.scale) * (chestSize - 3), inputs.yShift),
        priority = "extra-high",
    })
end

table.insert(item.picture.layers, {
    draw_as_shadow = true,
    filename = inputs.directory.."/graphics/entity/dynamic/shadow.png",
    width = 28, 
    height = 50, 
    scale = inputs.scale,
    shift = util.by_pixel(-((chestSize * singleWidth - 28) / 2) * inputs.scale, 4),
    priority = "extra-high",
})
table.insert(item.picture.layers, {
    draw_as_shadow = true,
    filename = inputs.directory.."/graphics/entity/dynamic/shadow.png",
    width = 74,
    x = 28,
    height = 50,
    scale = inputs.scale,
    shift = util.by_pixel(singleWidth * (chestSize - 2) / 2 * inputs.scale + 26 + 7, 4),
    priority = "extra-high",
})

end

function reskinHighChests(item, chestSize)
local singleHeight = 74
local firstGraphicsHeight = 22
local middleGraphicsHeight = 64
local preLastGraphicsHeight = 30
local lastGraphicsHeight = 26
local graphicsHeight = 148
local legHeight = 34

if chestSize == 2 then
    height = graphicsHeight
else
    height = firstGraphicsHeight
end

local heightDifference = chestSize * 64 - height
local shift = -(heightDifference / 2 + (singleHeight - 64)) * inputs.scale
local endShift = singleHeight * (chestSize - 2) / 2 * inputs.scale

local legDifference = chestSize * 64 - legHeight
local legShift = -(legDifference / 2 + (singleHeight - 64)) * inputs.scale

item.circuit_connector_sprites = nil

item.picture.layers = {
    {
        filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
        width = 64, 
        height = height, 
        scale = inputs.scale,
        shift = util.by_pixel(0, shift),
        priority = "extra-high",
    },
}

if chestSize > 2 then
    table.insert(item.picture.layers, {
        filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
        width = 3, 
        height = legHeight, 
        scale = inputs.scale,
        shift = util.by_pixel(-15.5, legShift),
        priority = "extra-high",
    })
    table.insert(item.picture.layers, {
        filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
        width = 3, 
        x = 61,
        height = legHeight, 
        scale = inputs.scale,
        shift = util.by_pixel(15, legShift),
        priority = "extra-high",
    })
    for i = 1, chestSize - 1 do
        table.insert(item.picture.layers, {
            filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
            width = 60, 
            height = middleGraphicsHeight, 
            y = firstGraphicsHeight,
            x = 2,
            scale = inputs.scale,
            shift = util.by_pixel(0, shift - 10.5 + (middleGraphicsHeight * inputs.scale) * i),
            priority = "extra-high",
        })
    end
    table.insert(item.picture.layers, {
        filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
        width = 62, 
        height = 38, 
        y = 84,
        x = 2,
        scale = inputs.scale,
        shift = util.by_pixel(0.5, shift + 46 + (middleGraphicsHeight * inputs.scale) * (chestSize - 2)),
        priority = "extra-high",
    })
    table.insert(item.picture.layers, {
        filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
        width = 64, 
        height = lastGraphicsHeight, 
        y = graphicsHeight - lastGraphicsHeight,
        scale = inputs.scale,
        shift = util.by_pixel(0, shift + 62 + (middleGraphicsHeight * inputs.scale) * (chestSize - 2)),
        priority = "extra-high",
    })
end

if chestSize > 2 then
    -- KORREKTUR FÜR FACTORIO 2.1: Nutzung der Standarddefinition
    if circuit_connector_definitions and circuit_connector_definitions["steel-chest"] then
        item.circuit_connector = circuit_connector_definitions["steel-chest"]
    else
        item.circuit_connector = {
            {
                points = {
                    wire = {
                        green = util.by_pixel(12.5, shift + 3.5),
                        red = util.by_pixel(12.5, shift + 0.5),
                    },
                    shadow = {
                        green = util.by_pixel(30.5, shift + 3.5 + 15), 
                        red = util.by_pixel(30.5, shift + 0.5 + 15),
                    }
                }
            }
        }
    end

    table.insert(item.picture.layers, {
        draw_as_shadow = true,
        filename = inputs.directory.."/graphics/entity/dynamic/high-shadow.png",
        width = 102, 
        height = 56, 
        scale = inputs.scale,
        shift = util.by_pixel(9.5, shift + 8),
        priority = "extra-high",
    })
    for i = 1, chestSize - 1 do
        table.insert(item.picture.layers, {
            draw_as_shadow = true,
            filename = inputs.directory.."/graphics/entity/dynamic/high-shadow.png",
            width = 102, 
            height = 64, 
            y = 56,
            scale = inputs.scale,
            shift = util.by_pixel(9.5, shift + 6 + (64 * inputs.scale) * i),
            priority = "extra-high",
        })
    end
    table.insert(item.picture.layers, {
        draw_as_shadow = true,
        filename = inputs.directory.."/graphics/entity/dynamic/high-shadow.png",
        width = 102, 
        height = 28, 
        y = 148 - 28,
        scale = inputs.scale,
        shift = util.by_pixel(9.5, shift + 29 + (64 * inputs.scale) * (chestSize - 1)),
        priority = "extra-high",
    })
else
    -- KORREKTUR FÜR FACTORIO 2.1: Nutzung der Standarddefinition
    if circuit_connector_definitions and circuit_connector_definitions["steel-chest"] then
        item.circuit_connector = circuit_connector_definitions["steel-chest"]
    else
        item.circuit_connector = {
            {
                points = {
                    wire = {
                        green = util.by_pixel(13, shift + 3.5 - 30),
                        red = util.by_pixel(13, shift + 0.5 - 30),
                    },
                    shadow = {
                        green = util.by_pixel(31, shift + 3.5 + 15 - 30), 
                        red = util.by_pixel(31, shift + 0.5 + 15 - 30),
                    }
                }
            }
        }
    end

    table.insert(item.picture.layers, {
        draw_as_shadow = true,
        filename = inputs.directory.."/graphics/entity/dynamic/high-shadow.png",
        width = 102, 
        height = height, 
        scale = inputs.scale,
        shift = util.by_pixel(10, 0.5),
        priority = "extra-high",
    })
end

end

function wideChestsAaiReskin.reskin()

local chestSize = 2
while true do
    local item = data.raw.container["WideChests_wide-steel-chest-"..chestSize]

    if not item then goto next end

    reskinWideChests(item, chestSize)

    chestSize = chestSize + 1
end

::next::

chestSize = 2
while true do
    local item = data.raw.container["WideChests_high-steel-chest-"..chestSize]

    if not item then goto finish end

    reskinHighChests(item, chestSize)

    chestSize = chestSize + 1
end

::finish::

end

5 days ago

Here's the updated functions.lua code for the new MergingChests v6.4.0. Like in the previous message you still need to update the info.json file to change "factorio_version": "2.1" and you can update "WideChests >= 6.4.0"

if not wideChestsAaiReskin then wideChestsAaiReskin = {} end

local inputs = {
directory = "aai-containers",
yShift = -2,
scale = 0.5
}

local function applyCircuitConnector(item, wg, wr, sg, sr)
local singleDef = (circuit_connector_definitions and circuit_connector_definitions["steel-chest"]) or {
points = {
wire = { green = wg, red = wr },
shadow = { green = sg, red = sr }
}
}

if type(item.circuit_connector) == "table" and #item.circuit_connector == 2 then
item.circuit_connector = { table.deepcopy(singleDef), table.deepcopy(singleDef) }
else
item.circuit_connector = { table.deepcopy(singleDef) }
end
end

function reskinWideChests(item, chestSize)
local singleWidth = 64
local firstGraphicsWidth = 96
local middleGraphicsWidth = 64
local lastGraphicsWidth = 96
local graphicsWidth = 128

local width = (chestSize == 2) and graphicsWidth or firstGraphicsWidth
local widthDifference = chestSize * singleWidth - width
local shift = -(widthDifference / 2) * inputs.scale
local endShift = singleWidth * (chestSize - 2) / 2 * inputs.scale

item.circuit_connector_sprites = nil

applyCircuitConnector(
item,
util.by_pixel(endShift + 29, -11),
util.by_pixel(endShift + 29, -14),
util.by_pixel(endShift + 47, 4),
util.by_pixel(endShift + 47, 1)
)

item.picture.layers = {
{
filename = inputs.directory.."/graphics/entity/dynamic/wide-chest.png",
width = width,
height = 74,
scale = inputs.scale,
shift = util.by_pixel(shift, inputs.yShift),
priority = "extra-high",
},
}

if chestSize > 2 then
for i = 1, chestSize - 3 do
table.insert(item.picture.layers, {
filename = inputs.directory.."/graphics/entity/dynamic/wide-chest.png",
width = 64,
height = 74,
x = 32,
scale = inputs.scale,
shift = util.by_pixel(shift + 8 + (middleGraphicsWidth * inputs.scale) * i, inputs.yShift),
priority = "extra-high",
})
end
table.insert(item.picture.layers, {
filename = inputs.directory.."/graphics/entity/dynamic/wide-chest.png",
width = lastGraphicsWidth,
height = 74,
x = 32,
scale = inputs.scale,
shift = util.by_pixel(shift + 48 + (middleGraphicsWidth * inputs.scale) * (chestSize - 3), inputs.yShift),
priority = "extra-high",
})
end

table.insert(item.picture.layers, {
draw_as_shadow = true,
filename = inputs.directory.."/graphics/entity/dynamic/shadow.png",
width = 28,
height = 50,
scale = inputs.scale,
shift = util.by_pixel(-((chestSize * singleWidth - 28) / 2) * inputs.scale, 4),
priority = "extra-high",
})
table.insert(item.picture.layers, {
draw_as_shadow = true,
filename = inputs.directory.."/graphics/entity/dynamic/shadow.png",
width = 74,
x = 28,
height = 50,
scale = inputs.scale,
shift = util.by_pixel(singleWidth * (chestSize - 2) / 2 * inputs.scale + 26 + 7, 4),
priority = "extra-high",
})
end

function reskinHighChests(item, chestSize)
local singleHeight = 74
local firstGraphicsHeight = 22
local middleGraphicsHeight = 64
local lastGraphicsHeight = 26
local graphicsHeight = 148
local legHeight = 34

local height = (chestSize == 2) and graphicsHeight or firstGraphicsHeight
local heightDifference = chestSize * 64 - height
local shift = -(heightDifference / 2 + (singleHeight - 64)) * inputs.scale

local legDifference = chestSize * 64 - legHeight
local legShift = -(legDifference / 2 + (singleHeight - 64)) * inputs.scale

item.circuit_connector_sprites = nil

item.picture.layers = {
{
filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
width = 64,
height = height,
scale = inputs.scale,
shift = util.by_pixel(0, shift),
priority = "extra-high",
},
}

if chestSize > 2 then
table.insert(item.picture.layers, {
filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
width = 3,
height = legHeight,
scale = inputs.scale,
shift = util.by_pixel(-15.5, legShift),
priority = "extra-high",
})
table.insert(item.picture.layers, {
filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
width = 3,
x = 61,
height = legHeight,
scale = inputs.scale,
shift = util.by_pixel(15, legShift),
priority = "extra-high",
})
for i = 1, chestSize - 1 do
table.insert(item.picture.layers, {
filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
width = 60,
height = middleGraphicsHeight,
y = firstGraphicsHeight,
x = 2,
scale = inputs.scale,
shift = util.by_pixel(0, shift - 10.5 + (middleGraphicsHeight * inputs.scale) * i),
priority = "extra-high",
})
end
table.insert(item.picture.layers, {
filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
width = 62,
height = 38,
y = 84,
x = 2,
scale = inputs.scale,
shift = util.by_pixel(0.5, shift + 46 + (middleGraphicsHeight * inputs.scale) * (chestSize - 2)),
priority = "extra-high",
})
table.insert(item.picture.layers, {
filename = inputs.directory.."/graphics/entity/dynamic/high-chest.png",
width = 64,
height = lastGraphicsHeight,
y = graphicsHeight - lastGraphicsHeight,
scale = inputs.scale,
shift = util.by_pixel(0, shift + 62 + (middleGraphicsHeight * inputs.scale) * (chestSize - 2)),
priority = "extra-high",
})
end

if chestSize > 2 then
applyCircuitConnector(
item,
util.by_pixel(12.5, shift + 3.5),
util.by_pixel(12.5, shift + 0.5),
util.by_pixel(30.5, shift + 3.5 + 15),
util.by_pixel(30.5, shift + 0.5 + 15)
)

table.insert(item.picture.layers, {
  draw_as_shadow = true,
  filename = inputs.directory.."/graphics/entity/dynamic/high-shadow.png",
  width = 102, 
  height = 56, 
  scale = inputs.scale,
  shift = util.by_pixel(9.5, shift + 8),
  priority = "extra-high",
})
for i = 1, chestSize - 1 do
  table.insert(item.picture.layers, {
    draw_as_shadow = true,
    filename = inputs.directory.."/graphics/entity/dynamic/high-shadow.png",
    width = 102, 
    height = 64, 
    y = 56,
    scale = inputs.scale,
    shift = util.by_pixel(9.5, shift + 6 + (64 * inputs.scale) * i),
    priority = "extra-high",
  })
end
table.insert(item.picture.layers, {
  draw_as_shadow = true,
  filename = inputs.directory.."/graphics/entity/dynamic/high-shadow.png",
  width = 102, 
  height = 28, 
  y = 148 - 28,
  scale = inputs.scale,
  shift = util.by_pixel(9.5, shift + 29 + (64 * inputs.scale) * (chestSize - 1)),
  priority = "extra-high",
})

else
applyCircuitConnector(
item,
util.by_pixel(13, shift + 3.5 - 30),
util.by_pixel(13, shift + 0.5 - 30),
util.by_pixel(31, shift + 3.5 + 15 - 30),
util.by_pixel(31, shift + 0.5 + 15 - 30)
)

table.insert(item.picture.layers, {
  draw_as_shadow = true,
  filename = inputs.directory.."/graphics/entity/dynamic/high-shadow.png",
  width = 102, 
  height = height, 
  scale = inputs.scale,
  shift = util.by_pixel(10, 0.5),
  priority = "extra-high",
})

end
end

function wideChestsAaiReskin.reskin()
local chestSize = 2
while true do
local item = data.raw.container["WideChests_wide-steel-chest-"..chestSize]

if not item then goto next end

reskinWideChests(item, chestSize)

chestSize = chestSize + 1

end

::next::

chestSize = 2
while true do
local item = data.raw.container["WideChests_high-steel-chest-"..chestSize]

if not item then goto finish end

reskinHighChests(item, chestSize)

chestSize = chestSize + 1

end

::finish::
end

New response