Subsurface - build beneath your base!

by Natha

Adds the ability to dig the underground, move item and fluids between surfaces and blow away pollution.

Content
3 months ago
1.1
2.06K
Environment Mining

g Great mod! Can share some features for it

9 months ago
(updated 9 months ago)

Hey, that's really nice.
I was planning to make such mod about 2 years ago, but gave up, because Factorio engine has two critical issues for underground surfaces realistic support: no way to turn off/decrease pollution diffusion ( https://forums.factorio.com/viewtopic.php?f=28&t=104070 ) , and need to make stupid limitations to make flying transport (aircrafts and others) to be unable explore underground freely. Complete demotivation after I learnt Wube is focused on monetizing on mods about other planet surfaces instead. But I can share my ideas and test implementation of one feature about pollution if you're interested - you can find me at factorio discord.

I didn't know about old version by StanFear, so instead I was looking at modmashsplinterunderground mod - it has interesting concept about rails transport that can be further improved without much efforts.

9 months ago

Hey, yes I also encountered the pollution problem the last days: https://forums.factorio.com/viewtopic.php?f=25&t=110815, but my workaround was to just "send back" pollution from empty to exposed chunks. Works...semi-well, but it works for now. But I want to see your idea.
I also came across ModMash and put some nice things on my todo list (vanilla rocks as cave walls), but we have to be careful to not copy them.
Just implement your stuff and do a pull request and if you want, I could add you as dev to the repo and share my Todo there...

9 months ago

You still interested?

8 months ago

I'm preparing markdown document with ideas description. It takes some time, because it's a big story. I'll make a pull request with the doc.

8 months ago

Hello there! I have recently discovered this mod, and while it does have its uses in its current state, I believe that the layered surfaces concept can be developed into something much more involved with the core gameplay, potentially transforming it into building your entire factory within multiple layers, and so I would like to present some of my own ideas that would hopefully help stir it in that direction.
While I originally started writing a lengthy explanation of the current state of the base game, of what it could have been, and explaining my thoughts and reasonings that led to these proposals, I have ultimately decided against it, as it would take too long to note down, span several screens, and ultimately hardly matters.

Here's the simplified list:
The drill should be made separate from the entrance to the underground layers, only serving as a tool to create an initial space, which could then be accessed by installing a relocatable stairs-type block. This would allow the player to install multiple entrances without having to worry about locking out certain tiles due to them being relocatable later, while also disconnecting the cost of the initial subsurface discovery from creating additional entrances.

The cost of creating new subsurfaces should be configurable, preferably also exponentially scaling it by depth, to discourage always taking the easier approach by creating an additional layer, and encouraging players to make the most use of every layer.

Mining out walls on a layer should cost resources, for the same reasons stated above, possibly requiring an item similar to the cliff explosives, preferably with configurable prices, and also scaled by layer.

Fluid I/O should be changed to a 1x1-tile undergound pipe instead of the large tank, as the latter takes too much space, and requires too large of an area for setup that you cannot efficiently design your base around without spacing everything out too much.

I/O structures should require setup in both places, similar to the underground belts and pipes, instead of the counterpart magically appearing on the other side, with the accessible spots initially marked by ghosts on adjacent layers.

I/O structures should not be split into separate items, but instead be the same item with its I/O direction adjustable via the rotation hotkey.

I/O structures should allow for spanning them across multiple layers within a single tile, with all of them sharing the same inventory.

All of the above would allow players to plan the core part of their base around multi-layered deeply interconnected setups without heavily separating them into the "logistics" or "train" layers, which is much more engaging when playing with overhaul mods that add lots of byproducts in their recipes, allowing for extension of existing setups as the game progresses without having to tear down and rebuild everything due to space limitations.

As for pollution, which this thread has touched upon, I believe it would be best to make a system that expels the currently accumulated pollution in every chunk out of the closest entrance one layer up at a time when there are no air vents installed/they are unable to keep up with the quantities produced, and air vents' transfer direction should be configurable, to allow to route your pollution towards pollution-absorbing buildings introduced by some mods, making them more useful.
It would also be great if air vents could be connected horizontally within the same layer/across adjacent layers, however that would be challenging to properly design without making it too cheaty of a system. It could be transformed and transported as a liquid, but there would have to be some heavy penalty in keeping it in liquid form for too long, as well as additional costs in transporting it across larger distances.

8 months ago

Good ideas but for most of them I wouldnt know how to implement or a lack of graphics. I would appreciate any coding help

8 months ago

For most of the ideas I need concrete solution approaches on how it should work, then I'm going to implement them

8 months ago

For most of the ideas I need concrete solution approaches on how it should work, then I'm going to implement them

It appears that AAI miners support mining entities that require fluid by consuming filled barrels from their inventory, so the mining cost could be implemented in the form of fluid requirement for the wall blocks, and either adding a new fluid and a recipe to produce it, or by simply using the already existing sulfuric acid, and scaling the cost by depth on surface generation. The base cost can be set to 1 acid/block, and a setting can be introduced to control the base value. You can have two settings for the scaling method, one for "type" - Linear/Exponential, and the other for "value" - either multiplier or exponent, depending on the type. Additionally, surfaces past a certain depth might be made to require separate resources. When playing with Bob's mods, Bob's Warfare introduces Nitroglycerin as fluid, which is used in production of ammo and is unlocked at green science, and since it is harder to produce than sulfuric acid, even directly requiring some amount of it in the recipe, it could be used as the "second tier" fluid, although the base cost would have to be different from sulfuric acid, at around 1 fluid/10 blocks.

For item I/O, the game already has a chest type that shares inventory between multiple entities, the "linked chest". All it requires is setting the same inventory ID on multiple containers that you want linked together. You can use this mod as a reference for an existing implementation: https://mods.factorio.com/mod/SchallAutolinkedChest
The best solution would probably be to copy all pure container types on startup, create a "linked chest" variation of them, then have the actual linking be done by using a selection tool on a container that invokes an event that checks the coordinates of adjacent surfaces for a container of the same type, and if found, replaces the chests with the modified entity, and links them together (if already linked, then does the backwards process of unlinking). To allow for creating separate connections within the same 2D coordinates without gaps between layers, you can make it so that the connection is only created/removed with the surface below/above depending on the state of an "alt" key. This does not require creating your own graphics for the entity and allows the players to use any container they want. For visually distinguishing between the two, you can overlay an arrow-type icon of sorts onto the sprite on creation.

For fluids, you can create a single hidden container, and connect every input/output pipe to it on setup. The setup and actual entities can be done the same way as with the item containers, as in going through all existing pipes, and creating a copy of those, and then using a selection tool for linkage.

Varying cost for initial surface creation and separating the drill from entrance placement can be done by making the "drill" be an assembler, use a crafting recipe with the "resource cost" used as input and having void/stone as output, then performing the surface creation upon the required number of "crafts" completed by the "drill". The drill initializes the chunks below it if not already present, clears them of the wall blocks in a small area, then disappears, but leaves some sort of "flag" when it does, so that you don't lose the spot. Could be a tinted copy of the wooden power pole with 0 connection length, set to not drop anything on destruction. For player transfer, I checked out the Factorissimo mod (https://mods.factorio.com/mod/factorissimo-2-notnotmelon-surfaceAPIfix), and it does the very inefficient method of iterating over every existing factory building once every tick, and compares the player and entrance position. A better method, I believe, would be to use the LandMine prototype and set the teleportation as the triggered action upon activation. You can have it check for whether a player is holding an "alt" key to allow for bi-directional movement. You don't really have to link them together, and can just check for the existence of the counterpart on spot, notifying the player with a flyover text when there is no available destination, and you can have placing the initial one on the other side require a separate entity that disappears upon placement, and creates one on the surface below/above (again, "alt" key). This one would probably require its own sprite, but you can just use anything for the time being.

For pollution, you can create a "polluted water" fluid, and a "air scrubbing" assembling machine with a negative pollution production that produces said "polluted water" fluid. I don't know how you could reliably prevent players from storing it in large tanks, and periodically manually flushing the fluid storage, but that is obviously cheating, as that is obviously not what you are intended to do, so the players can manage it themselves. The only issue with the assembly machine approach is that it seems that it would be hard to limit it to only produce the fluid when there is actual pollution absorbed, but the only shitty workaround I can think for it that doesn't require running checks and manually stopping the machine is to have the assembling machine have a hidden item input for the recipe, overlay an invisible "biter nest" (EnemySpawner) on top of the machine on creation, set it to spawn an entity on 'x' pollution consumed that invokes a script on creation that checks the entitity's position, gets the assembling machine on top of it, if it exists and has available space, then it adds one placeholder item into the input, and if not, returns the pollution back into the chunk, and then destroys itself. This approach would probably be more performance-friendly than constant iterations over all assemblers, but still bad due to entity creation/destruction overheads, although I'm not sure about the actual numbers. Going back to the actual fluid produced, the fluid can be disposed of by feeding it into a polluter "assembly machine" that has the mirrored pollution production values and voids the fluid as its recipe. This allows the players to transfer the pollution around both horizontally and vertically (via fluid I/O), but gives them the freedom of choice for where to release it.

New response