Subsurface - build your base underground!

by Natha

While everyone is looking up to space, other planets and the rest of the universe, there is a whole world buried directly underneath us. Use this opportunity to declutter your factory logistics by routing it under your base and explore the underground!

Content
a month ago
1.1 - 2.1
8.12K
Transportation Logistics Trains Environment Mining

b Crash on on_init when Space Exploration hasn't loaded yet (get_surface_type errors)

2 days ago
(updated 16 hours ago)

Got a non-recoverable crash on a fresh game with Subsurface + Space Exploration. Looks like it depends on your overall mod list. It started after adding Krastorio 2, which changes what order mods load in.

Error:

Error while running event Subsurface::on_init()
Error when running interface function space-exploration.get_surface_type: __space-exploration__/scripts/zone.lua:308: attempt to index field 'zones_by_surface' (a nil value)
    __space-exploration__/scripts/zone.lua:308: in function 'from_surface_index'
    __Subsurface__/control.lua:477: in function 'allow_subsurfaces'
    __Subsurface__/control.lua:67: in function <__Subsurface__/control.lua:61>

What's happening:

In on_init, allow_subsurfaces() calls Space Exploration's get_surface_type remote interface. If Subsurface happens to load/init before Space Exploration does, SE hasn't set up its internal zone data yet, and the call crashes.

In my log, the actual control-stage load order was:
Krastorio2 -> Subsurface -> space-exploration
so Subsurface initialized before SE. This looks sensitive to overall mod list composition. Space Exploration lists (?) Krastorio2 as a load-order-affecting optional dependency, so adding Krastorio 2 pushes SE later in the load order, which in my case flipped things relative to Subsurface.

What to change:

In info.json, add Space Exploration to your dependencies list like this:
"(?) space-exploration"
That (?) prefix (not just ?) tells Factorio "load me after Space Exploration if it's installed" — same format Space Exploration itself already uses for its own Krastorio 2 dependency. That should fix the load-order problem without touching any other code.

Environment: Factorio 2.1, Subsurface 1.1.27, Space Exploration 0.7.60, Krastorio 2 2.1.2.

New response