Page 1 of 1

surface.set_tiles() and ungenerated chunks?

Posted: Tue Oct 27, 2020 9:06 pm
by Illiander42
Can anyone confirm the behaviour of using surface.set_tiles() to set tiles in chunks that aren't generated yet?

Re: surface.set_tiles() and ungenerated chunks?

Posted: Tue Oct 27, 2020 9:18 pm
by Klonan
It will work, no problem there

They will be overwritten by map generation, unless you also set chunk generated status:
https://lua-api.factorio.com/latest/Lua ... ted_status

Re: surface.set_tiles() and ungenerated chunks?

Posted: Wed Oct 28, 2020 7:17 am
by Illiander42
Cheers.

Follow-up question:

Is there an easy way to set a default tile? I'm having trouble navigating the docs about autoplace settings.

Re: surface.set_tiles() and ungenerated chunks?

Posted: Wed Oct 28, 2020 8:15 am
by darkfrei
The main default tile is "not-on-map", if I can right understand what you call "default tile".

Re: surface.set_tiles() and ungenerated chunks?

Posted: Wed Oct 28, 2020 10:21 am
by Illiander42
What I mean is if you remove all autoplace settings, the map is filled with "grass-1".

I'd like to know if there's an easy way to change that to "deepwater" without using OnChunkGenerated(), because the autoplace documentation is really unclear, and I can't undertand how to do something that simple with it.

Re: surface.set_tiles() and ungenerated chunks?

Posted: Wed Oct 28, 2020 12:32 pm
by Deadlock989
Illiander42 wrote:
Wed Oct 28, 2020 10:21 am
What I mean is if you remove all autoplace settings, the map is filled with "grass-1".

I'd like to know if there's an easy way to change that to "deepwater" without using OnChunkGenerated(), because the autoplace documentation is really unclear, and I can't undertand how to do something that simple with it.
For a surface filled with a specific ground tile you can remove all autoplace settings and then set the probability of the desired tile super-high and the probability of every other tile (loop through them) super-low using map_gen_settings.property_expression_names.

For water tiles I'm less certain. Those are tied to elevation and are treated differently in the starting area. You might have success just fiddling with the "water" property of the settings. If not then I suspect you would probably have to open the Pandora's box of NamedNoiseExpression and create a new expression that produces zero or negative elevation ( = water) everywhere.

Yes, this stuff is brain-curdling.

Re: surface.set_tiles() and ungenerated chunks?

Posted: Wed Oct 28, 2020 1:09 pm
by Bilka
Illiander42 wrote:
Wed Oct 28, 2020 7:17 am
Is there an easy way to set a default tile? I'm having trouble navigating the docs about autoplace settings.
Illiander42 wrote:
Wed Oct 28, 2020 10:21 am
What I mean is if you remove all autoplace settings, the map is filled with "grass-1".

I'd like to know if there's an easy way to change that to "deepwater" without using OnChunkGenerated(), because the autoplace documentation is really unclear, and I can't undertand how to do something that simple with it.
/c game.create_surface("test", {property_expression_names = {["tile:deepwater:probability"] = 100}})

Re: surface.set_tiles() and ungenerated chunks?

Posted: Wed Oct 28, 2020 5:06 pm
by Illiander42
So I looked a bit more into that, and found some notes that imply that this code should do what I want:

Code: Select all

local surface = game.get_surface("nauvis")
local mgs = surface.map_gen_settings
mgs.property_expression_names = {["tile:deepwater:probability"] = 100}
surface.map_gen_settings = mgs
But it's not doing what I expect it to do.

---

(And is there a better place to run this than in on_tick()?)