map_gen_settings not effectively writable?

Post all other topics which do not belong to any other category.
Post Reply
neoc
Long Handed Inserter
Long Handed Inserter
Posts: 83
Joined: Sun Apr 24, 2016 4:31 pm
Contact:

map_gen_settings not effectively writable?

Post by neoc »

I just tried to mess around with surface.map_gen_settings, especially autoplace_controls["enemy-base"], on the in-game console.

I started a map with size="none" for enemy bases and tried to change it to size="high". When I tried to confirm the successful write via printing the value, it didn't show the new value but still "none". Generating chunks via force.chart didn't generate biter spawners. The API says surface.map_gen_settings is RW. Am I doing it wrong?

Daid
Fast Inserter
Fast Inserter
Posts: 163
Joined: Sun Jul 03, 2016 7:42 am
Contact:

Re: map_gen_settings not effectively writable?

Post by Daid »

Most likely you need to write the whole map_gen_settings structure in 1 go, not modify a value of it.

So:
surface.map_gen_settings.autoplace_controls["enemy-base"].size = "high"
Won't work.

local mgs = surface.map_gen_settings
msg.autoplace_controls["enemy-base"].size = "high"
surface.map_gen_settings = mgs

Will most likely work. The API works like this in quite a few places.

neoc
Long Handed Inserter
Long Handed Inserter
Posts: 83
Joined: Sun Apr 24, 2016 4:31 pm
Contact:

Re: map_gen_settings not effectively writable?

Post by neoc »

Ha, that did the job, thanks! My first guess was that the structure mag_gen_settings is referring to might not be writable, but the reference ("pointer") itself is, so you would have to make a copy of the structure, change it and change the reference to it. Maybe this is what happens behind the scenes when you create a new reference to an immutable structure.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: map_gen_settings not effectively writable?

Post by Nexela »

For the most part anything that returns a table and supports read/write i.e map_gen_settings, fluid_box will need the whole table written back to it.

Post Reply

Return to “General discussion”