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?
map_gen_settings not effectively writable?
Re: map_gen_settings not effectively writable?
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.
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.
Re: map_gen_settings not effectively writable?
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.
Re: map_gen_settings not effectively writable?
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.