This script generates a requiredDataFiles.json file suitable for use with tes3mp servers, based on your OpenMW configuration (openmw.cfg). It parses your configuration file to determine data paths, identifies plugin files (ESP, ESM, etc.) within those paths, orders them according to the content list specified in the configuration, calculates CRC32 hashes for each plugin, and outputs the results in a JSON format that tes3mp can understand.
No special installation is required. Simply save the script (e.g., main.py) and ensure you have Python 3 installed. You will also need the zlib and json modules, which are typically included in standard Python installations.
-
Save the Script: Save the provided Python code as a
.pyfile (e.g.,main.py). -
Run from the Command Line: Use the following command to execute the script:
python main.py --cfg_file --output_file
- Replace `` with the absolute path to your
openmw.cfgfile. - Replace `` with the absolute path where you want the
requiredDataFiles.jsonfile to be created.
Example:
python main.py --cfg_file "/home/user/openmw/openmw.cfg" --output_file "/home/user/tes3mp/requiredDataFiles.json"
- Replace `` with the absolute path to your
-
tes3mp Integration: Place the generated
requiredDataFiles.jsonfile in the directory specified by your tes3mp configuration (usually alongside your tes3mp executable). Ensure your tes3mp server is configured to use this file.
- Configuration Parsing: Automatically parses your
openmw.cfgfile to determine data paths and the content order. - Plugin Discovery: Locates all plugin files (with extensions
.esp,.esm,.ESP,.ESM,.omwaddon) within the specified data paths. - Content-Based Ordering: Orders plugins according to the order specified in the
content=lines of youropenmw.cfgfile. This is crucial for correct mod loading in OpenMW and tes3mp. - CRC32 Hash Generation: Calculates the CRC32 hash of each plugin file for verification.
- JSON Output: Generates the
requiredDataFiles.jsonfile in the format expected by tes3mp. - Error Handling: Includes basic error handling for missing
openmw.cfgfiles and when no plugins are found. - Command-Line Arguments: Uses
argparseto handle command-line arguments for flexibility and ease of use.
- Python 3: The script is written for Python 3.
- zlib: Built-in Python module for CRC32 calculation.
- json: Built-in Python module for JSON output.
- os: Built-in Python module for file system operations.
- re: Built-in Python module for regular expression matching.
The script is organized into a Parser class with the following static methods:
parse_openmw_cfg(cfg_file): Parses theopenmw.cfgfile to extract data paths and content files.find_plugin_extensions(data_paths): Finds all plugin files with the specified extensions within the data paths.order_plugins_by_content(plugins, content_files): Orders the plugins based on the content list.calculate_crc32(filepath): Calculates the CRC32 hash of a file.generate_json(plugins): Generates the JSON output in the required format.main(cfg_file, output_file): The main function that orchestrates the entire process.
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on this GitHub repository.
This script is released under the GNU GPL 3.
inpv