mod_settings¶
- decode_mod_settings(
- input_stream: BytesIO,
Reads a byte stream of a Factorio PropertyTree and decodes it into a JSON- like
dict. Primarily used for decoding mod-settings.dat.
- encode_mod_settings(
- destination: BytesIO,
- property_tree: dict,
- factorio_version: tuple[int, ...] | None =
None, Writes an encoded PropertyTree from a ModSettings data object to the byte buffer, which can then be serialized to a mod-settings.dat file. This function is separate from the file creation step to allow for more flexibility, if desired.
- read_mod_settings(mods_path: str) ModSettings¶
Reads a mod_settings.dat file located at the
mods_pathdirectory. Returns a dict populated with the startup, per-user runtime, and global runtime settings organized per mod.- Parameters:
- mods_path: str¶
The path to the directory where ‘mod-settings.dat’ is located (usually next to the mods it configures).
- Returns:
A dictionary with 3 keys:
"startup","runtime-global", and"runtime-per-user". Each entry value is dictionary of applicable mods, which contain all of their respective settings.
- write_mod_settings(
- mods_path: str,
- mod_settings: ModSettings,
Writes a mod-settings.dat file to a specified folder with the contents of
mod_settings. Note that no validation is done with the contents ofmod_settings, so any out-of-bounds checking is left to the user.- Parameters:
- mods_path: str¶
The path to the directory where a ‘mod-settings.dat’ file will be created or overwritten.
- mod_settings: ModSettings¶
A properly formatted ModSettings dictionary.
- class ModSettings¶
- enum PropertyTreeType(value)¶
An enumeration.
- Member Type:
int
Valid values are as follows:
-
NONE =
<PropertyTreeType.NONE: 0>¶
-
BOOL =
<PropertyTreeType.BOOL: 1>¶
-
NUMBER =
<PropertyTreeType.NUMBER: 2>¶
-
STRING =
<PropertyTreeType.STRING: 3>¶
-
LIST =
<PropertyTreeType.LIST: 4>¶
-
DICTIONARY =
<PropertyTreeType.DICTIONARY: 5>¶
-
SIGNED_INTEGER =
<PropertyTreeType.SIGNED_INTEGER: 6>¶
-
UNSIGNED_INTEGER =
<PropertyTreeType.UNSIGNED_INTEGER: 7>¶