Adding custom map gen presets.

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
shortnr
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Nov 29, 2016 7:08 am
Contact:

Adding custom map gen presets.

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

grimdanfango
Inserter
Inserter
Posts: 40
Joined: Thu Sep 10, 2015 6:38 pm
Contact:

Re: Adding custom map gen presets.

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

grimdanfango
Inserter
Inserter
Posts: 40
Joined: Thu Sep 10, 2015 6:38 pm
Contact:

Re: Adding custom map gen presets.

Post 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

User avatar
moon69
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Sep 18, 2016 6:53 pm
Contact:

Re: Adding custom map gen presets.

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

gruther4
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Feb 09, 2018 5:31 pm
Contact:

Re: Adding custom map gen presets.

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

cybernoise
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Dec 20, 2017 3:21 am
Contact:

Re: Adding custom map gen presets.

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

User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 768
Joined: Sun May 07, 2017 10:16 am
Contact:

Re: Adding custom map gen presets.

Post 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.
Mods: Shortcuts for 1.1, ick's Sea Block, ick's vanilla tweaks
Tools: Atom language pack
Text quickly seems cold and unfriendly. Be careful how you write and interpret what others have written.
- A reminder for me and all who read what I write

Post Reply

Return to “Modding discussion”