Page 1 of 1

Adding custom map gen presets.

Posted: Sat May 13, 2017 10:59 pm
by shortnr
Hi, everyone!

I created a custom map gen preset (inside map-gen-presets.lua) that is a combination of rail world and marathon (large, rich patches spread far apart, expensive recipes/research and biters don't expand) and I can select it as a preset.

Unfortunately, it's name in the list is "Unknown key: 'map-gen-preset-name.rail-world-marathon'". This doesn't affect it's function, but it is annoying to look at. In addition, the description is the same string.

I attempted to add my own name and description into the base.cfg, but it just modified the name and description of the previous entry (rail-world).

Does anyone know how to do this properly? My method must be slightly hacky, if it's not working.

Re: Adding custom map gen presets.

Posted: Fri May 19, 2017 12:19 am
by grimdanfango
Any luck with this? I can't work out how I should define a "map-gen-preset-name", and it is unsightly.

I'm also trying to work out how to use data:extend to add another preset to the list using a mod rather than directly editing the file, but if I specify: name = "default", it overwrites the other presets and just leaves one in the list, or if I specify a different name, it errors telling me there can only be one instance of "map-gen-presets".

Anyone successfully added a preset using a mod *and* managed to register a description string?

Re: Adding custom map gen presets.

Posted: Fri May 19, 2017 12:45 am
by grimdanfango
Aaand as usual, the moment I post about it, I work it out!

I downloaded the "KoS Presets" mod, and used that as a template - it's pretty straightforward once someone demonstrates how to do it properly :-P

Re: Adding custom map gen presets.

Posted: Fri Jul 14, 2017 2:26 pm
by moon69
Works for me :)

Except "Water" setting... in GUI it allows Frequency and Size, but in API doc MapGenSettings only a single value is specified for Water that appears to control the Size... how does one preset the Water frequency?

Re: Adding custom map gen presets.

Posted: Fri Feb 09, 2018 5:33 pm
by gruther4
Just to clarify, the issue that the original poster found was because they hadn't put entries in the locale folder for localized text strings.

Also, the water frequency seems to be mapped to terrain_segmentation for some reason.

Re: Adding custom map gen presets.

Posted: Thu Feb 15, 2018 5:04 pm
by cybernoise
Would be nice to be able to simply "Save" current mapsettings at the mapgenui and to "load" Presets.
Saved in a seperated .lua which can be edited for modders as well.

Re: Adding custom map gen presets.

Posted: Wed Apr 21, 2021 6:53 pm
by ickputzdirwech
I created a custom map gen preset today and I got two tips for everyone who tries to do the same:

1. If you want to use the same intervals as you can set in the GUI, round the numbers to 8 digits after the comma like 0.33333333 and 0.16666667.
2. Define the preset as:

Code: Select all

data.raw["map-gen-presets"].default["preset-name"] = {...}
You can get table.insert() to work as well but defining locales doesn't work properly in that case (instead of using the name of the preset you have to use the index). Another alternative is to copy the whole prototype from the base game files and add your preset to it, but this won't work in case more than one mod tries to add presets.