Page 1 of 1

[0.17] autoplace_controls for no rocks

Posted: Sun Jul 14, 2019 5:01 am
by XaLpHa89
What is the property to tell the map generator not to create rocks?
.

Code: Select all

local map_gen_settings = {}
-- map_gen_settings.default_enable_all_autoplace_controls = false
map_gen_settings.autoplace_controls = { [ 'coal' ] = { frequency = 'none', size = 'none', richness = 'none' }, [ 'stone' ] = { frequency = 'none', size = 'none', richness = 'none' }, [ 'copper-ore' ] = { frequency = 'none', size = 'none', richness = 'none' }, [ 'uranium-ore' ] = { frequency = 'none', size = 'none', richness = 'none' }, [ 'iron-ore' ] = { frequency = 'none', size = 'none', richness = 'none' }, [ 'crude-oil' ] = { frequency = 'none', size = 'none', richness = 'none' }, [ 'trees' ] = { frequency = 'none', size = 'none', richness = 'none' }, [ 'enemy-base' ] = { frequency = 'none', size = 'none', richness = 'none' } }
map_gen_settings.autoplace_settings = { entity = { treat_missing_as_default = false, settings = { frequency = 'none', size = 'none', richness = 'none' } }, decorative = { treat_missing_as_default = true, settings = { frequency = 'none', size = 'none', richness = 'none' } } }
map_gen_settings.cliff_settings = { name = 'cliff', cliff_elevation_0 = 0, cliff_elevation_interval = 0 }
map_gen_settings.width = 300
map_gen_settings.height = 300
.
20190714065530_1.jpg
20190714065530_1.jpg (499.46 KiB) Viewed 1693 times

Re: [0.17] autoplace_controls for no rocks

Posted: Sun Jul 14, 2019 6:48 pm
by slippycheeze
Rocks are decoratives. You didn't even touch those with anything pictured in your settings. "stone", there, is the resource like coal or iron, which you mine.

See the "autoplace_settings" and "property_expression_names" in MapGenSettings for the syntax for them, and the base mod prototype lua for where the whole shebang is defined.

You are probably most interested in the rock_autoplace_settings function in there, which is used to define the settings for the decals that count as rocks in base.

Keep in mind that mods are not obliged to use the same autoplace information, and can even place stuff manually despite your desires. Given that, if I was you, I'd probably iterate over the defined decoratives, find everything that flagged itself as "I'm a rock for the deconstruction planner", and then emit a "don't every place this thing, specifically" rule for each one.

That way if someone has a rock that isn't using the same noise layer, control variables, or whatever, it'll still be banned.

You can see the NiceFill mod for an example finding and banning water tiles, if you want.

Re: [0.17] autoplace_controls for no rocks

Posted: Mon Jul 15, 2019 7:05 am
by darkfrei
slippycheeze wrote:
Sun Jul 14, 2019 6:48 pm
Rocks are decoratives.
Rocks https://wiki.factorio.com/Rock are simple entities, not decoratives.
https://wiki.factorio.com/Prototype/SimpleEntity
https://wiki.factorio.com/Data.raw#simple-entity

Re: [0.17] autoplace_controls for no rocks

Posted: Mon Jul 15, 2019 9:39 pm
by slippycheeze
darkfrei wrote:
Mon Jul 15, 2019 7:05 am
slippycheeze wrote:
Sun Jul 14, 2019 6:48 pm
Rocks are decoratives.
Rocks https://wiki.factorio.com/Rock are simple entities, not decoratives.
https://wiki.factorio.com/Prototype/SimpleEntity
https://wiki.factorio.com/Data.raw#simple-entity
You are quite correct. My mistake: I thought they were in the wrong layer, and since that file also places a pile of decoratives, I didn't end up checking closely enough. I believe that, despite my error, the rest of my comment is accurate since entity placement and decorative placement share the same controls, and I did name the core noise expressions, etc, correctly at least. :)

Re: [0.17] autoplace_controls for no rocks

Posted: Tue Jul 16, 2019 10:43 am
by XaLpHa89
What do I have to do to apply it?

Re: [0.17] autoplace_controls for no rocks

Posted: Wed Jul 17, 2019 12:16 am
by slippycheeze
From nicefill, where I struggled through the how to stop water turning up when it didn't use the default noise expression:

Code: Select all

            for name, _ in pairs(game.tile_prototypes) do
                if name:find("water") then
                    map_gen_settings.property_expression_names["tile:"..name..":probability"] = -1000
                end
            end
...and thank you to the people who patiently explained why my initial belief that water = 0 should do the same thing was wrong, and what the right way was.

That'll do the one-by-one version. You can extend it appropriately following the documentation for other things. Obviously, rocks are entities, so you want a rule for "entity" instead of tile. The -1000 is a magical "low enough" number that it means "never" - zero is not "never", it is "just use the noise as-is". -math.huge also works, I believe, if you want to be more extreme about it. :)

I'd suggest you walk through the defined entity prototypes and find all the rocks that way, then use their name in a similar loop. The LuaEntityPrototype has the read-only property "count_as_rock_for_filtered_deconstruction" at runtime which will let you filter them out of the list of all entities.

You can probably do the same in the data-final-fixes stage, since it is also part of the prototype there, but you will have to make sure nobody else generates rocks in the final phase too.

Once the game starts the control phase, though, the set is fixed, so you only need to build that list once when control.lua is loaded, not every time you want to touch map generator settings.

Re: [0.17] autoplace_controls for no rocks

Posted: Wed Jul 17, 2019 6:08 am
by XaLpHa89
I found the part of the program in the mod NiceFill, only somehow it does not work anymore. The program part generates the following error:

Code: Select all

attempt to index field 'property_expression_names' (a nil value)
But I have a success to report, following ensures that no rocks are generated.

Code: Select all

map_gen_settings.autoplace_settings = { entity = { treat_missing_as_default = false, settings = { frequency = 'none', size = 'none', richness = 'none' } }, decorative = { treat_missing_as_default = true, settings = { frequency = 'none', size = 'none', richness = 'none' } } }

Re: [0.17] autoplace_controls for no rocks

Posted: Wed Jul 17, 2019 8:30 am
by Klonan
Just set the entity autoplace to nil