convert map exchange string to map generator settings
- trad_emark
- Inserter
- Posts: 33
- Joined: Fri Sep 23, 2016 8:54 pm
- Contact:
convert map exchange string to map generator settings
Is it possible to generate the map-settings.json and map-gen-settings.json from map exchange string or directly in the gui?
I know I can start a new game and upload the save to the server, but I would prefer to "acquire" the settings anyway, for multiple reasons.
- It would help me to better understand which value is which.
- It would allow me to generate save with some values outside ranges available in the gui (I especially like to set negative time or pollution factors for biters evolution ) and to set some of the other properties that aren't available in the gui at all.
Thanks for any hints
I know I can start a new game and upload the save to the server, but I would prefer to "acquire" the settings anyway, for multiple reasons.
- It would help me to better understand which value is which.
- It would allow me to generate save with some values outside ranges available in the gui (I especially like to set negative time or pollution factors for biters evolution ) and to set some of the other properties that aren't available in the gui at all.
Thanks for any hints
Re: convert map exchange string to map generator settings
Came to ask the same thing.
I would love to see either an in-game or a web based Exchange String to JSON converter.
For in-game, just have a JSON button on the normal Exchange String export screen perhaps.
I would love to see either an in-game or a web based Exchange String to JSON converter.
For in-game, just have a JSON button on the normal Exchange String export screen perhaps.
Re: convert map exchange string to map generator settings
I am not near my home PC, but I believe these commands would generate the data
/c game.write_file("map-settings.json", serpent.block(game.map_settings))
/c game.write_file("map-gen-settings.json", serpent.block(player.surface.map_gen_settings))
This will output to the "script-output" folder.
/c game.write_file("map-settings.json", serpent.block(game.map_settings))
/c game.write_file("map-gen-settings.json", serpent.block(player.surface.map_gen_settings))
This will output to the "script-output" folder.
-
- Manual Inserter
- Posts: 2
- Joined: Sun Dec 22, 2019 1:21 am
- Contact:
Re: convert map exchange string to map generator settings
I would also like to have this ability to output the map config files in JSON format from within Factorio. It would be helpful to be able to pass the config files to a server admin, instead of having to mess with save game files. Perhaps the server admin would like to tweak a few settings before spinning up the game?
I did try the commands that @billbo99 provided, but they didn't work. I'm not sure if it's because I'm running 0.18.6 or if it's something else.
This command doesn't give any errors:
/c game.write_file("map-settings.json", serpent.block(game.map_settings))
But, the contents of the file (and thus game.map_settings) are not what is expected:
This command does give an error...
/c game.write_file("map-gen-settings.json", serpent.block(player.surface.map_gen_settings))
... as shown below:
I tried to do a little troubleshooting myself, but my knowledge of (Factorio's) Lua scripting is lacking.
For example: I can understand that the map settings would be in the game object, but why would the map generation settings be in player.surface?
Would it be foolish to presume that they might be stored in the same object?
I did try the commands that @billbo99 provided, but they didn't work. I'm not sure if it's because I'm running 0.18.6 or if it's something else.
This command doesn't give any errors:
/c game.write_file("map-settings.json", serpent.block(game.map_settings))
But, the contents of the file (and thus game.map_settings) are not what is expected:
Code: Select all
{
__self = "userdata"
}
/c game.write_file("map-gen-settings.json", serpent.block(player.surface.map_gen_settings))
... as shown below:
Code: Select all
Cannot execute command. Error: (command):1:attempt to index global 'player' (a nil value)
For example: I can understand that the map settings would be in the game object, but why would the map generation settings be in player.surface?
Would it be foolish to presume that they might be stored in the same object?
Re: convert map exchange string to map generator settings
Try this:
from here
Note the output will need a bit of adjustment to be fully preset compatible.
Code: Select all
/c game.write_file("my-map-settings.txt", serpent.block(game.parse_map_exchange_string(">>>eNpjYBBiYGYAgwZ7EOZgSc5PzIHxQJgrOb+gILVIN78oFVmYM 7moNCVVNz8TVXFqXmpupW5SYjGKYo7Movw8dBNYi0vy81BFSopSU 4uRRbhLixLzMktz0fUyMH6/sbyxoUWOAYT/1zMo/P8PwkDWA6BfQ JiBsQGiEigGA6zJOZlpaQwMCo5A7ASSZmRkrBZZ5/6waoo9I0SNn gOU8QEqciAJJuIJY/g54JRSgTFMkMwxBoPPSAyIpSVAK6CqOBwQD IhkC0iSkbH37dYF349dsGP8s/LjJd+kBHtGQ1eRdx+M1tkBJdlB/ mSCE7NmgsBOmFcYYGY+sIdK3bRnPHsGBN7YM7KCdIiACAcLIHHAm 5mBUYAPyFrQAyQUZBhgTrODGSPiwJgGBt9gPnkMY1y2R/cHMCBsQ IbLgYgTIAJsIdxljBCmQ78Do4M8TFYSoQSo34gB2Q0pCB+ehFl7G Ml+NIdgRgSyP9BEVBywRAMXyMIUOPGCGe4aYHheYIfxHOY7MILzE EjVF6AYIzPMkzCjILSAAzMDAgCTxWTGtfUAK4Wh8A==<<<")))
Note the output will need a bit of adjustment to be fully preset compatible.
-
- Manual Inserter
- Posts: 2
- Joined: Sun Dec 22, 2019 1:21 am
- Contact:
Re: convert map exchange string to map generator settings
I think I may have stumbled upon the answer:
This basically gets the exchange string, runs it through the internal parser, runs it through the Serpent pretty printer, then outputs it all to the map-settings.json file in the script-output folder. (On Windows, this would be %APPDATA%\Factorio\script-output)
Both the map settings and the map gen settings get output to the same file(which might be fine, I think). [edit: I guess not]
Caveat: I haven't actually tested this on a headless server yet.
Also Caveat: This command will disable achievements. Save your game before you use this, if that's important to you.
EDIT: I should have refreshed the page before posting my answer. Thanks, Squelch, for that info. If I hadn't worked it out myself, I'm sure that would have pointed me in the right direction. Also good to know that the output isn't directly usable as the headless server config file. I'm sure a bit of comparison to the example config files will help clear that up!
Code: Select all
/c game.write_file("map-settings.json", serpent.block(game.parse_map_exchange_string(game.get_map_exchange_string())))
Both the map settings and the map gen settings get output to the same file
Caveat: I haven't actually tested this on a headless server yet.
Also Caveat: This command will disable achievements. Save your game before you use this, if that's important to you.
EDIT: I should have refreshed the page before posting my answer. Thanks, Squelch, for that info. If I hadn't worked it out myself, I'm sure that would have pointed me in the right direction. Also good to know that the output isn't directly usable as the headless server config file. I'm sure a bit of comparison to the example config files will help clear that up!
Re: convert map exchange string to map generator settings
No problem, and as you may have noticed, I too struggled in the same way. In fact it was deja vu there for a moment, and I had to check that I was not in my own topicIchibanDashi wrote: ↑Tue Feb 18, 2020 3:22 amI think I may have stumbled upon the answer:
..
EDIT: I should have refreshed the page before posting my answer. Thanks, Squelch, for that info. If I hadn't worked it out myself, I'm sure that would have pointed me in the right direction. Also good to know that the output isn't directly usable as the headless server config file. I'm sure a bit of comparison to the example config files will help clear that up!
There is also
table_to_json(data) you might want to use too.
ie.
Code: Select all
/c game.write_file("my-map-settings.json", serpent.block(game.table_to_json(game.parse_map_exchange_string(">>>eNpjYBBiYGYAgwZ7EOZgSc5PzIHxQJgrOb+gILVIN78oFVmYM 7moNCVVNz8TVXFqXmpupW5SYjGKYo7Movw8dBNYi0vy81BFSopSU 4uRRbhLixLzMktz0fUyMH6/sbyxoUWOAYT/1zMo/P8PwkDWA6BfQ JiBsQGiEigGA6zJOZlpaQwMCo5A7ASSZmRkrBZZ5/6waoo9I0SNn gOU8QEqciAJJuIJY/g54JRSgTFMkMwxBoPPSAyIpSVAK6CqOBwQD IhkC0iSkbH37dYF349dsGP8s/LjJd+kBHtGQ1eRdx+M1tkBJdlB/ mSCE7NmgsBOmFcYYGY+sIdK3bRnPHsGBN7YM7KCdIiACAcLIHHAm 5mBUYAPyFrQAyQUZBhgTrODGSPiwJgGBt9gPnkMY1y2R/cHMCBsQ IbLgYgTIAJsIdxljBCmQ78Do4M8TFYSoQSo34gB2Q0pCB+ehFl7G Ml+NIdgRgSyP9BEVBywRAMXyMIUOPGCGe4aYHheYIfxHOY7MILzE EjVF6AYIzPMkzCjILSAAzMDAgCTxWTGtfUAK4Wh8A==<<<"))))
Re: convert map exchange string to map generator settings
For the record, since this is the result in google when trying to export map-settings.json for a server, here is a combination of what work:
Ready to be copy-pasted by anyone (and surely older-me )
Code: Select all
/c game.write_file("map-settings.json", game.table_to_json(game.parse_map_exchange_string(game.get_map_exchange_string())))
/c game.write_file("map-gen-settings.json", game.table_to_json(game.player.surface.map_gen_settings))
Re: convert map exchange string to map generator settings
update for Space Age (game.write_file replaced with helpers.write_file):larandar wrote: ↑Sat Sep 26, 2020 6:43 pmFor the record, since this is the result in google when trying to export map-settings.json for a server, here is a combination of what work:
Ready to be copy-pasted by anyone (and surely older-me )Code: Select all
/c game.write_file("map-settings.json", game.table_to_json(game.parse_map_exchange_string(game.get_map_exchange_string()))) /c game.write_file("map-gen-settings.json", game.table_to_json(game.player.surface.map_gen_settings))
Code: Select all
/c helpers.write_file("map-gen-settings.json", helpers.table_to_json(game.player.surface.map_gen_settings))
Re: convert map exchange string to map generator settings
For Nauvis playthrought is fine but if you plan on playing Space Age and landing on other planets you would realize after landing on the second planet your settings didn't carry on the other planets because you are using game.player.surface.map_gen_settings those are the map gen settings only for the current surface and that json doesn't contain any other information about the other planets that are on the map exchange string.arye321 wrote: ↑Wed Oct 23, 2024 9:16 am
update for Space Age (game.write_file replaced with helpers.write_file):
Code: Select all
/c helpers.write_file("map-gen-settings.json", helpers.table_to_json(game.player.surface.map_gen_settings))
That's what happened viewtopic.php?t=118374
I would recomend for generating the map-gen-settings.json using the game.default_map_gen_settings instead, the json does contain the information about the other planets and it won't give this problem heres the command with the map-settings included, also the map-settings contains more information(Pollution, Enemies, Asteroids...) and the map-gen-settings inside.
Code: Select all
/c helpers.write_file("map-settings.json", helpers.table_to_json(helpers.parse_map_exchange_string(game.get_map_exchange_string())))
/c helpers.write_file("map-gen-settings.json", helpers.table_to_json(game.default_map_gen_settings))