Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
frenzied_coder
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Jun 05, 2017 1:27 pm
Contact:

Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?

Post by frenzied_coder »

I found myself in a situation where I wanted to parse a map exchange string during the settings stage of a mod. LuaHelpers.parse_map_exchange_string() seems to do what I want, but it's not available in the settings stage. Given the output of the function is settings objects, it is surprising that it cannot be used in the construction of settings during the settings stage of a mod. Perhaps I'm not understanding what this function is for.

Taking a step back, I might be approaching this whole situation wrong. What I really want to do is allow a human player to fiddle with the sliders in the new game window, and then hand over their choices to my program, which is a combination of Python and Lua, and the result is a server creating a new map with their given settings. (This is in the context of the Archipelago randomizer framework.)

The current approach that I'm adapting is that the human manually types out yaml/json data that becomes a MapGenPreset, which is given to factorio --create ... --preset .... This seems to have its own limitations, such as not being able to configure spoil rate due to the difference between MapGenPresetDifficultySettings and DifficultySettings, so I might need to switch to using --map-settings and --map-gen-settings anyway.

My dream would be that the manually typed up yaml accepts a map exchange string that the human pastes in, and then the python code invokes the factorio command line interface to create a modded game save with almost exactly the settings in the exchange string, with only the seed being randomized.

Is there any way use a map exchange string to create a new game save with a headless server command line invocation, possibly including a mod that is generated by python code that has access to the map exchange string?
Rseding91
Factorio Staff
Factorio Staff
Posts: 16586
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?

Post by Rseding91 »

Because it’s parsing the strings into ordered and validated map settings. However in the settings stage there are no prototypes so it can’t translate names to prototypes or validate anything.
If you want to get ahold of me I'm almost always on Discord.
frenzied_coder
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Jun 05, 2017 1:27 pm
Contact:

Re: Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?

Post by frenzied_coder »

Thanks for the quick reply! It sounds like using parse_map_exchange_string() to make a MapGenPreset is not the right approach then.

Is there any plan for allowing a map exchange string as a command line parameter when creating a save with factorio --create?
Rseding91
Factorio Staff
Factorio Staff
Posts: 16586
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?

Post by Rseding91 »

There are no plans but I could add it for 2.1.
If you want to get ahold of me I'm almost always on Discord.
frenzied_coder
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Jun 05, 2017 1:27 pm
Contact:

Re: Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?

Post by frenzied_coder »

That would definitely simplify the experience for my users!
Post Reply

Return to “Modding interface requests”