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?
Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?
-
frenzied_coder
- Burner Inserter

- Posts: 9
- Joined: Mon Jun 05, 2017 1:27 pm
- Contact:
Re: Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?
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
- Burner Inserter

- Posts: 9
- Joined: Mon Jun 05, 2017 1:27 pm
- Contact:
Re: Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?
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?
Is there any plan for allowing a map exchange string as a command line parameter when creating a save with factorio --create?
Re: Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?
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
- Burner Inserter

- Posts: 9
- Joined: Mon Jun 05, 2017 1:27 pm
- Contact:
Re: Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?
That would definitely simplify the experience for my users!
-
frenzied_coder
- Burner Inserter

- Posts: 9
- Joined: Mon Jun 05, 2017 1:27 pm
- Contact:
Re: Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?
I see this new CLI option in the experimental branch:
Thanks for making it happen! I'll try out using it soon.
Code: Select all
--exchange-string arg The exchange string for use with --create,
--start-server-load-scenario or
--generate-map-preview. If provided, this is loaded first and
then any other setting arguments are
processed.
-
frenzied_coder
- Burner Inserter

- Posts: 9
- Joined: Mon Jun 05, 2017 1:27 pm
- Contact:
Re: Why can LuaHelpers.parse_map_exchange_string() not be used in the settings stage?
Using the reverse engineering effort here: https://github.com/rfvgyhn/factorio-exc ... ing-parser , I was able to make my dreams come true! My program now allows the user to specify a map exchange string in a yaml configuration, then my python code queries it (checks for enemies enabled) and modifies it (randomizes the seed), and then passes it as a parameter to create a new game.
Thanks Rseding91 for getting this in 2.1! <3
Thanks Rseding91 for getting this in 2.1! <3
