Subsurface - build beneath your base!

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
10 days ago
1.1 - 2.0
5.35K
Environment Mining

i [Fixed] Allowing other mods to make there own walls

i would like to be able to change the recipe output of the drill and change the drops of walls based on what subsurface depth they are on, and as far as i can tell thats not currently possible.

if it is please let me know, and i understand if you dont think this is worth the effort to add

4 months ago

Good idea, i could implement a remote interface to change the cave walls. Surface drilling is basicly just mining a resource patch which can also be altered.

4 months ago

Please have a look at Github and test it, the latest commit contains an interface. Check "interface-example.lua" for instructions how to implement your own stuff

i will check in the morning and let you know how it works and what i think

the variable 'subsurface_level' cannot actualy be used, unless i set it myself. i also have no idea what to do with function(surface, depth, position). also the example value of 2k is likely way to high as it puts out 55K resources with mining prod of 40%, copying the defult output of stone from the default recipy on the surface, which normaly would give 1.3k. the matching value is ~50

i also cannot get my walls to spawn.

The mod Subsurface - build beneath your base! (1.1.5) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event Subsurface::on_init()
Error when running interface function Midori_Stoneblock.subsurface_register_walls: Midori_Stoneblock/control.lua:21: attempt to perform arithmetic on global 'subsurface_level' (a nil value)
stack traceback:
Midori_Stoneblock/control.lua:21: in function <Midori_Stoneblock/control.lua:19>
stack traceback:
[C]: in function 'call'
Subsurface/control.lua:47: in function 'register_subsurface_walls'
Subsurface/control.lua:60: in function <Subsurface/control.lua:56>

my last code:
-- Remote interface. replace "mymod" with your mod name
remote.add_interface("Midori_Stoneblock", {

-- This function defines which resource should be used when drilling to subsurfaces. It can be used for different mining results.
-- The resource must be of category "subsurface-hole".
-- Since multiple mods can have this function, the resource with the highest priority will be used. Default priority is 0.
-- surface and depth parameters refer to the surface where the drill is placed.
subsurface_hole_resource = function(surface, depth, position)
    local priority = 1
    local resource = "deep-drill"
    local amount = 100
    return priority, resource, amount
end,

-- This function defines custom subsurface walls with custom mining results.
-- The walls must be of type "cliff" - best practice is to copy from Subsurface and change what needed (pictures, drops)
-- The noise expression returns a priority value (default is 0), the wall with the highest priority will be used.
-- The expression can make use of the variable "subsurface_level".
subsurface_register_walls = function()
    return {
        ["deep-wall"] = 100
    }
end

})

im dumb, function(surface, depth, position) are used to make the mining results change with depth, surface, and position if you use formulas

my wall issue may just be because i dont know anything about noise expressions

3 months ago

Subsurface_level is not a lua variable, it is a variable used in noise expressions. Just define an expression that returns a value >0

so am i supposed to set subsurface_level to an equation? what variables do i use? no constant i have set spawns my rock walls.
i deepcopied the "subsurface-wall" entity, do i need to copy something else to pass in?

i thought subsurface_level was a variable because of this line:
-- The expression can make use of the variable "subsurface_level".

3 months ago

You should dive into noise expressions as they allow you to set different entities for different positions and underground levels. The most basic thing is a named noise expression with expression = 1 which replaces all occurrences of the default wall with your custom wall

hey, how is function register_subsurface_walls() supposed to work? if im reading it right it looks like anything i define isnt getting passed through, and when i add logs they are called, but any log i add to read the contents of subsurface_wall_expressions are empty (even directly after the merge), and i couldnt find anything else that calls that function from the interface

also, i tried setting my wall = 1 based on how the example said i should formatting it, and i never saw one of my walls. i used editor extensions to make sure i made them correctly, and they do exist
do i have a formatting error?
subsurface_register_walls = function()
return {
["deepwall"] = 1
}
end

3 months ago

I'll create a mod later that adds these features for you to see how it's supposed to work

thank you

3 months ago
(updated 3 months ago)

https://github.com/NathaU/factorio-subsurface/issues/34
Use with the newest commit of Subsurface

ahhh, i see what i was doing wrong now, thank you

(thought i sent this yesterday)
your test mod works, altho the amount of uranium to get past the first layer took forever to test if it did or not

3 months ago
(updated 3 months ago)

I always use
/c game.player.selected.mining_target.deplete()
For that

i didnt know about that command, i was just spamming super becons with super speed modules from editor extensions

New response