Deadlock's Stacking Beltboxes & Compact Loaders


Adds minimalist 1x1 loaders and stacking beltboxes for 5x belt compression for ores, plates and some intermediate products

Content
2 years ago
0.17 - 1.1
89.5K
Logistics

b Stacked vanilla ores use old icons

3 years ago

The graphics for stacks for vanilla ores (iron, copper) use the old icons for those items. It looks weird to have the items with the new graphics go in, then something looking completely different come out. Could you update to use the new graphics?

3 years ago

Made a patch to remove the custom icons for vanilla ores and use generated ones instead so it uses the new graphics. It also adds variations for item entities on belts for stacked items with variations. This way stacked ores on belts have the same varied look as normal ores.

--- prototypes/vanilla_stacks.lua
+++ prototypes/vanilla_stacks.lua
@@ -4,6 +4,6 @@

 for tier,items in ipairs(DBL.VANILLA_ITEMS) do
    for _,item in pairs(items) do
-       deadlock.add_stack(item, string.format("__deadlock-beltboxes-loaders__/graphics/icons/square/stacked-%s.png", item), string.format("deadlock-stacking-%d", tier), DBL.VANILLA_ICON_SIZE)
+       deadlock.add_stack(item, nil, string.format("deadlock-stacking-%d", tier), DBL.VANILLA_ICON_SIZE)
    end
 end
--- prototypes/create_stack.lua
+++ prototypes/create_stack.lua
@@ -19,7 +19,7 @@
 local items_to_update = {}
 function DBL.create_stacked_item(item_name, item_type, graphic_path, icon_size, stack_size, mipmap_levels)
    DBL.debug(string.format("Creating stacked item: %s", item_name))
-   local temp_icons, stacked_icons --, this_fuel_category, this_fuel_acceleration_multiplier, this_fuel_top_speed_multiplier, this_fuel_value, this_fuel_emissions_multiplier
+   local temp_icons, stacked_icons, stacked_pictures --, this_fuel_category, this_fuel_acceleration_multiplier, this_fuel_top_speed_multiplier, this_fuel_value, this_fuel_emissions_multiplier
    if graphic_path then
        stacked_icons = { { icon = graphic_path, icon_size = icon_size, icon_mipmaps = mipmap_levels } }
    else
@@ -52,6 +52,26 @@
                table.insert(stacked_icons, table.deepcopy(layer))
            end
        end
+
+       if base_item.pictures and #base_item.pictures then
+           stacked_pictures = {}
+           local pictures = base_item.pictures
+           for i = 1, #pictures do
+               local stacked_layers = { { filename = "__deadlock-beltboxes-loaders__/graphics/icons/square/blank.png", scale = 1, size = 32 } }
+               for j = 1, -1, -1 do
+                   local p = (i + j + 1 - 1) % #pictures + 1
+                   local picture = table.deepcopy(pictures[p])
+                   if not picture.layers then
+                       picture.scale = 0.85 * (picture.scale or 1)
+                       picture.shift = util.add_shift(picture.shift, {0, j*3/picture.size})
+                       table.insert(stacked_layers, picture)
+                   else
+                       DBL.log_warning(string.format("Item %s picture %d uses layers", item_name, p))
+                   end
+               end
+               stacked_pictures[i] = { layers = stacked_layers }
+           end
+       end
    end
    data:extend({
        {
@@ -59,6 +79,7 @@
            name = string.format("deadlock-stack-%s", item_name),
            localised_name = {"item-name.deadlock-stacking-stack", get_localised_name(item_name), stack_size},
            icons = stacked_icons,
+           pictures = stacked_pictures,
            stack_size = math.floor(data.raw[item_type][item_name].stack_size/stack_size),
            flags = {},
            subgroup = string.format("stacks-%s", get_group(item_name, item_type)),
3 years ago
(updated 3 years ago)

The graphics for stacks for vanilla ores (iron, copper) use the old icons for those items. It looks weird to have the items with the new graphics go in, then something looking completely different come out. Could you update to use the new graphics?

This was on my to-do list but if I'm honest I'm never going to reach it. I rarely have time to play Factorio now and when I do it's never in a game with vanilla ores.

Using the built-in "layered icon maker" feature is not recommended, there are potential performance implications in late game on low/mid-range PCs, leaving it in the mod was one of my bigger mistakes.

If anyone wants to contribute something derived from the new ore icons (and all the other updated 64x64 mipmapped sets), you can submit them via Github.

billbo99 was working on some Python scripts to derive baked stack icons automatically, I don't know where that got to.

3 years ago

I've been using the above patch for a while now with no issues. I do have a higher-end PC and my base isn't massive, but I'm also in a game with lots of modded items that don't have baked stacked icons. I understand the reasoning behind that approach but it seems a shame not to take advantage of the game's built-in functionality for composing icons to make it more flexible. Are there really significant performance impacts to using layered icons? I would imagine it's very performant considering it's the just same sprite scaled and translated a few times.

3 years ago
(updated 3 years ago)

Are there really significant performance impacts to using layered icons? I would imagine it's very performant considering it's the just same sprite scaled and translated a few times.

I think it depends on many factors. For higher-end PCs I think you are likely to hit the CPU bottleneck in a megabase well before rendering ever becomes an issue, even if you completely ignore trains and go full buses. So if you are running any kind of built-for-gaming PC you are probably going to be fine.

I trust what posila, the Wube dev in charge of the rendering engine, says, and he advised against using layered icons for items if at all possible. The only vanilla items to do it are filled barrels and they have 2 layers, and who fills a megabase with barrels? At the end of the day it is 4x the number of icon renders per belt item (a transparent background because of icon scaling shenanigans and three copies of the item icon). You say "a few times", but fully zoomed out there can be thousands and thousands of them on screen at once. On the other hand, since DSB saves you 5x the quantity of belt items in the first place, essentially you are only losing most of that benefit and are back slightly ahead of square one.

So essentially it is the kind of thing I would be fine about doing for my own play, but feel more reluctant about putting out as a mod for people to try and run on their Intel graphics chip laptops. A composited single layer icon is the optimal choice for an item icon that's going to be shipped around in mass quantities and ores are firmly in that category.

If you know your way around Python I posted some scripts on the main forums for turning layered icons into single PNGs.

Otherwise hopefully someone will volunteer to do this eventually.

3 years ago

Thanks for the explanation. I agree that the balance between performance and compatibility is important. I probably won't work on making the pre-stacked icons since I haven't run into issues myself, but thanks for the info.

3 years ago

I made a mod that updates the icons. It's not all that good, but you may find it agreeable.

New response