Factorissimo 2 - notnotmelon fork 🍴


A fork of Factorissimo 2 focused on improving performance by implementing several 1.1 features. Can improve performance by 10X or higher. Also fixes several bugs from the original version.

Content
1 year, 3 months ago
1.1
53.9K
Logistics

b [1.2.3] surface_override doesn't register the overridden surface name

6 months ago

I encountered the Space Factorissimo bug https://mods.factorio.com/mod/space-factorissimo-updated/discussion/62f24d587d4d88d0f006c738 and saw the new surface_override API option, so I was attempting to fix it. Then I noticed the option doesn't actually work: in control.lua,

       local surface_name = 'factory-floor-' .. global.next_factory_surface
       local surface = game.surfaces[layout.surface_override or surface_name]

Notice surface_name is not overridden, so not only a new surface with the overridden name isn't created if it doesn't exist, but the new factory is registered to the wrong surface, so remote_api.find_surrounding_surface doesn't work, and one can't exit factory buildings.

The fix is trivial:

--- a/control.lua
+++ b/control.lua
@@ -322,8 +322,8 @@ local function create_factory_position(layout)
        if (settings.global['Factorissimo2-same-surface'].value) then
                global.next_factory_surface = 1
        end
-       local surface_name = 'factory-floor-' .. global.next_factory_surface
-       local surface = game.surfaces[layout.surface_override or surface_name]
+       local surface_name = layout.surface_override or ('factory-floor-' .. global.next_factory_surface)
+       local surface = game.surfaces[surface_name]
        if surface == nil then
         surface = game.create_surface(surface_name, {width = 2, height = 2})
         surface.daytime = 0.5

New response