Caves


Adds a cave system to the game that contains the resources instead of the normal surface.

Content
7 years ago
0.15
22
Mining

b [Solved] Crash when using with Building Plattform

7 years ago
(updated 7 years ago)

When using the Mod Building Plattform and Caves, I always get the following error:
Error while running event Caves::on_tick (ID 0)
Unknown entity: building-platform.
stack traceback:
Caves/control.lua:595: in function 'finalizeChunk'
Caves/control.lua:633: in function 'createMoreChunks'
Caves/control.lua:691: in function <Caves/control.lua:677>

The error will occure when you generate ores only in caves or on surface and caves.

7 years ago
(updated 7 years ago)
7 years ago
(updated 7 years ago)

unfortunately for now i don't think it is possible to use both mods together (i will add it to the description).

There are a couple of problems:

My mod doesn't consider that some autoplace-controls might actually be tiles and not entities. therefore you get the above error message. I could fix that (but it wouldn't be enough).

My mod regenerates resources(=entities) once the cave is ready. But there doesn't seem to be a function to regenerate tiles in the factorio api. (LuaSurface only has regenerate_entity and regenerate_decorative). therefore i cannot regenerate the building platforms, which then don't appear in caves.
Even if such a function would exist, it would pretty much break the look of caves since this would overwrite the cave-walls, so i don't expect a nice result here.

it seems to me like the building platform mod prevents the placement of cave entrances or exits (not sure on the details, i just saw that otherwise good positions would not succeed. my mod checks for being able to place transport-belts and entrances/exits).
but at the same time, since there are no building platforms in the cave, it means that it is impossible to create an entrance at all.
i am not sure if the building platforms mod can be configured to ignore cave entrances or exits; from my brief look it seems like a hardcoded list of supported mods is used so this would need to be changed in the building platform mod.

so depending on how you expect it to work:
If you expect entrances to only be placeable on platforms, then this can't be achieved at the moment because i can't create platforms in caves. (also good luck finding a place where a platform would overlap above and below ground)
If you expect cave entrances to be placeable without platforms, then i think in the building platforms mod cave entrances and exits need to be excluded. also you should add building-platform to my mods settings under resources that only generate on the surface.

7 years ago

Building platform mod author here.

I don't have lots of time, I don't work tomorow so I will take a look then but some things I would like to point :

  • For the autoplace problem, I need to look more closely tomorow. But can't an autoplace be told to ignore some surface if needed ? Or can't you check that an autoplace related entity is a tile and not a resources ? But like I said I will take a look tomorow.

  • If my mod block building of other mod, there is an API for other mod to create special rules (see function documentation here. Or you can just ask me and I will add custom rules in the mod in next release. So I can unblock entrance/exit if you want for the next release. If I create custom rule for your mod, user will have the choice to allow or block your buildings in my mod config.

  • If we find that there is no way to generate platform in cave, I can do like I have done for Factorissimo2 allow all building on cave ground while keeping the restriction for other ground.

7 years ago
(updated 7 years ago)

I am building up the autoplace for the cave surface, by reusing the autoplace from nauvis and then adjusting it based on the settings. for resources that users don't want in the cave, i would set their "size" to "none" so they don't appear. so currently users could already add building-platform in my config for being ignored in the cave.
I can determine if it is a tile or entity and should handle this special case on my side (however i don't think i can implement a correct tile generation, without writing my own generator)
From a gameplace perspective i think it anyway wouldn't make sense to have platforms in the cave as it makes more sense to extract the resources from caves somewhere and then haul them to the platforms on nauvis.

thanks for the link to the API, didn't realize those functions where callable. I will play around with this, but the idea would then be to call
foo = addPlatform("cave-ground",false)
blockOnly(type="accumulator", "mine-exit", foo)
i think it makes more sense to do this in my mod, as the entity type is subject to change. (also if i add ground variations)

i think that pretty much should then work as expected; only a tiny issue would be if a user for example through explosive landfill has replaced cave-ground with dirt (or placed concrete on top); in that case it wouldn't be possible to place any longer.
Do you have a plan for a function like blockNever(type,pattern)? in my opinion that would be bit cleaner.
i think a mod setting in Building Platform for entrances/exits wouldn't really be benefitial currently, at least not until i am able to generate tiles in caves.

7 years ago

turns out it wasn't that simple; addPlatform does a lot more than i expected :)
i have the tile prototype already (and i need that prototype for the more common use case that both mods are not used together), so creating it via addPlatform isn't really ideal.
also it doesn't really make sense to spend one of the collision mask layers for this; they probably make more sense for other use cases (like actual platforms on the surface).

also though about the opposite problem too. from within caves it is possible to create exits leading to nauvis. These would also be prevented. So to fix that, i would need to restrict the mine-entrances to a "not-really-platform" containing all the surface tile types.
meaning that if we do it like that, i would need two platform layers, which together with the main one leaves just a single layer free...

so finally i think the easiest would be either to have an API where i can specify to never block mine-entrances/exits, or to have them excluded from within Building Platform

7 years ago
(updated 7 years ago)

I will take a look later today when I have time, I just wanted to talk about on the API use. I know that it is not clear now, the website that is coming soon will explain things better.

I see what you have in mind, making your ground a platform then block the exit everywhere but not on your ground. It will work but it is not the ideal solution.
You only need to unblock your entrance/exit from my platform so no need to add a new platform. Better use the following code :

--no need to unrestrict the entrance if accumulator are not blocked
if(not settings.startup[buildingplatform.constants.unrestrictPowerSetting].value) then
    --second parameter is a LUA pattern so you need '%' before any real '-'
    blockAllBut("accumulator", "mine%-exit") 
end

This code need to be executed after data-updates phase of my mod but before data-final-fixes phase. and will allow the exit to be placed anywhere.

Know that the API will be redone better after the website is finished and will have better function to remove a restriction without checking my mod config (a blockNever of sort). I will PM mod author that I know use my API if I make any change that will break the compatibility or for any function that become deprecated days before I release so they have time to update. But for the time being the code I gave you will unblock your exit so they are placeable outside platform.

I will have time in a couple hour to see this better for the autoplace problem.

7 years ago

you can unrestrict entrance by adding another blockAllBut like I have done in the previous post.

7 years ago

thanks, that cleared my confusion a bit. (i would suggest a rename or an alias:blockAllBut->addException)

as far as i could tell:
no blockAllBut call, checkbox "unrestrict power" not ticked: not placeable
both blockAllBut calls checkbox "unrestrict power" not ticked: placeable
no blockAllBut call, checkbox "unrestrict power" ticked: placeable
both blockAllBut calls checkbox "unrestrict power" ticked: placeable

so do i need the if depending on the setting? to me it seems like adding an exception is possible even if a user already selected that a type is unrestricted.

7 years ago
(updated 7 years ago)

blockAllBut is not for exception at first when I make it. It does block all but the one listed, but multiple blockAllBut will not restrict all that have been called. So When my config told my mod to block power (which contain accumulator), you need to block all but your entrance so it add an exception. Because it block all but the one listed it mustn't be call when they haven't been block by my mod or another or it will block all other when they shouldn't.

You are right for the four affirmation, but for the fourth, you will block all accumulator as a side effect so that's why I added an if test on the config.

I agree that the API need a proper function for exception like that to avoid making other mod check for my config. For now that's how it works ;)

7 years ago
(updated 7 years ago)

After seeing for the error report at the beginning of this thread, I post this message to share my finding.

Concerning autoplace and platform generation.

You can't regenerate tile but since all tile are created when the chunk is created, you can see where platform has been placed by the game by checking tile name before you replace them with ground/wall), so you can either :

  • Don't replace tile generated that come from autoplace with your ground tile (you can check all autoplace against tile existence like I have done for entity below to find all tile that come from autoplace)

  • Save the position of tile that come from autoplace and restore them at the last stage of your generation. (only tile that should be where you have ground, not wall).

Thats will make platform (or any other tile that a mod can add by autoplace) in cave.

Apart from having platform in cave, you can make the reported error disappear by using the following code :

        if(game.entity_prototypes[res]) then
            table.insert(resourcesToRegenerate, res) 
        end

in your finalizeChunk function when your are building the table of resource (line 583). So that table will only include autoplace things that are entity and nothing else so you won't regenerate something that is not entity.

Only using that last code and not what I suggest earlier will make your mod work with mine but no platform will spawn in cave. Since cave seem to be for resource and nothing else it could works to have no platform here as miner, belts, chest are not restricted. But I haven't see a way to move liquid in the entrance. Sulfuric acid (for uranium) need to be brought via barrel ? If so, there will be a problem as assembling machine can only be place on platform so no mean to unbarrel them in cave if no platform here.

7 years ago

thanks, yes something like that i had in mind as well. i didn't realize the unbarreling problem. bringing in barrels via belts worked good enough for me, therefore i didn't add a liquid transportation entrance as of now.
however with the default configuration, oil is generated on the surface, so that isn't an issue (unless it would be badly configured).

i think i might save the tile positions but need to test if that works well enough; as i need to save them once the chunk is created this can result in a huge list (they are processed as a kind of backlog)

7 years ago

Just wanted to throw my thank you in here to both of you for working out a solution.

7 years ago

thanks :)
sorry, got stuck a bit when trying to solve it generally. maybe i will upload an intermediate solution this weekend

7 years ago

finally got around to releasing a fix for this problem, should work in 0.1.7
(just keep in mind that no platforms spawn within the cave currently, and that "building-platform" must be set in the settings as a resource to spawn on the surface)

7 years ago

Hi, thanks for your work. The first tries I wasn't able to get it working, but then I noticed that I still had RSO on -.-
My initial test shows that I seems to work and now I'm going to start a new map :-)
Thanks a lot.

New response