surface.set_tiles() and ungenerated chunks?

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
Illiander42
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Mon Feb 05, 2018 10:01 am
Contact:

surface.set_tiles() and ungenerated chunks?

Post by Illiander42 »

Can anyone confirm the behaviour of using surface.set_tiles() to set tiles in chunks that aren't generated yet?

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 4944
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: surface.set_tiles() and ungenerated chunks?

Post 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

Illiander42
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Mon Feb 05, 2018 10:01 am
Contact:

Re: surface.set_tiles() and ungenerated chunks?

Post 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.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2883
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: surface.set_tiles() and ungenerated chunks?

Post by darkfrei »

The main default tile is "not-on-map", if I can right understand what you call "default tile".

Illiander42
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Mon Feb 05, 2018 10:01 am
Contact:

Re: surface.set_tiles() and ungenerated chunks?

Post 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.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2384
Joined: Fri Nov 06, 2015 7:41 pm

Re: surface.set_tiles() and ungenerated chunks?

Post 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.
"If Stalin had a good writeup on programming, would linking that be dangerous?"

Bilka
Factorio Staff
Factorio Staff
Posts: 2790
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: surface.set_tiles() and ungenerated chunks?

Post 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}})
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Illiander42
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Mon Feb 05, 2018 10:01 am
Contact:

Re: surface.set_tiles() and ungenerated chunks?

Post 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()?)

Post Reply

Return to “Modding discussion”