2021-04-02 18:51:47 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# <https://wiki.factorio.com/Mod_settings_file_format>
|
|
|
|
# <https://forums.factorio.com/59851>
|
|
|
|
# <https://www.dropbox.com/sh/uscmj9y3cjfwpsr/AAD35_ZZu64EBi0awLA07fxga?dl=0>
|
|
|
|
# <https://github.com/credomane/factoriomodsettings/blob/master/src/FactorioModSettings.js>
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
from pathlib import Path
|
|
|
|
import struct
|
|
|
|
import json
|
|
|
|
|
|
|
|
sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "script-resources"))
|
|
|
|
import factorio.property_tree
|
|
|
|
|
|
|
|
|
|
|
|
with open(Path.home() / ".factorio" / "mods" / "mod-settings.dat", "rb") as f:
|
|
|
|
|
2021-04-18 15:06:47 +00:00
|
|
|
version_main: int
|
|
|
|
version_major: int
|
|
|
|
version_minor: int
|
|
|
|
version_developer: int
|
2021-04-02 18:51:47 +00:00
|
|
|
version_main, version_major, version_minor, version_developer = struct.unpack(
|
|
|
|
"<HHHH", f.read(8)
|
|
|
|
)
|
|
|
|
|
|
|
|
always_false_flag = factorio.property_tree.read_bool(f)
|
|
|
|
assert not always_false_flag
|
|
|
|
|
|
|
|
deserialized_data = {
|
|
|
|
"factorio_version": {
|
|
|
|
"main": version_main,
|
|
|
|
"major": version_major,
|
|
|
|
"minor": version_minor,
|
|
|
|
"developer": version_developer,
|
|
|
|
},
|
|
|
|
"data": factorio.property_tree.read(f),
|
|
|
|
}
|
|
|
|
|
|
|
|
print(json.dumps(deserialized_data, indent=2))
|