Skip to content

inpv/openmw_cfg_to_tes3mp_json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

openmw.cfg to tes3mp requiredDataFiles.json plugin list generator

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.

Installation

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.

Usage

  1. Save the Script: Save the provided Python code as a .py file (e.g., main.py).

  2. 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.cfg file.
    • Replace `` with the absolute path where you want the requiredDataFiles.json file to be created.

    Example:

    python main.py --cfg_file "/home/user/openmw/openmw.cfg" --output_file "/home/user/tes3mp/requiredDataFiles.json"
  3. tes3mp Integration: Place the generated requiredDataFiles.json file in the directory specified by your tes3mp configuration (usually alongside your tes3mp executable). Ensure your tes3mp server is configured to use this file.

Features

  • Configuration Parsing: Automatically parses your openmw.cfg file 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 your openmw.cfg file. 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.json file in the format expected by tes3mp.
  • Error Handling: Includes basic error handling for missing openmw.cfg files and when no plugins are found.
  • Command-Line Arguments: Uses argparse to handle command-line arguments for flexibility and ease of use.

Dependencies

  • 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.

Script Details

The script is organized into a Parser class with the following static methods:

  • parse_openmw_cfg(cfg_file): Parses the openmw.cfg file 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.

Contributing

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.

License

This script is released under the GNU GPL 3.

Author

inpv

About

A simple pure Python script to convert your openmw.cfg into a server-ready requiredDataFiles.json based on data paths and content files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages