Python library for Stellaris modding, including a mod merger and script generator.
Project description
Synthetipy
A Python library for Stellaris modding
Mod Merger
Overview
- The Mod Merger auto merges the resolvable edit conflicts in multiple Stellaris mod script files (Paradox Script) into a patch mod.
- It uses AST-based (gumtree algorithm) matching and edit generation to combine changes from different mods while preserving the original structure and logic and minimizing conflicts as much as possible.
Key features
- Scans and merges script files from multiple mods while preserving directory structure.
- Uses normalization + AST matching for accurate diffs and edits.
- Produces merge outputs suitable for testing or as a final merged mod directory.
Quick start
from pathlib import Path
from synthetipy.script_merger.interface import *
EXAMPLE_CONFIG = {
'common': {
# excluded folders
'inline_scripts': FOLDER_EXCLUDE,
"scripted_effects": FOLDER_EXCLUDE,
"scripted_triggers": FOLDER_EXCLUDE,
"script_values": FOLDER_EXCLUDE,
"on_actions": FOLDER_EXCLUDE,
"economic_plans": FOLDER_EXCLUDE,
# ordered folders
"colony_automation": FOLDER_ORDERED,
"colony_automation_exceptions": FOLDER_ORDERED,
# default: unordered merge (default behavior)
"buildings": FOLDER_UNORDERED
},
}
GAME_FOLDER = Path("D:/SteamLibrary/steamapps/common/Stellaris")
MODS = [
Path("path_to_mod1"),
Path("path_to_mod2")
]
OUTPUT_FOLDER = Path("path_to_output_folder")
merger = BatchMerger(GAME_FOLDER, MODS, OUTPUT_FOLDER, EXAMPLE_CONFIG)
merger.run()
Limitations
What is resolvable edit conflicts?
- Stellaris and other Paradox games use a "last one wins" approach to mod loading, which means that if two mods modify the same script object (e.g., a building, or a technology), the one that is loaded last will overwrite the changes of the previous one. This can lead to conflicts when multiple mods try to modify the same object, and it can be difficult for modders to resolve these conflicts manually.
- The Mod Merger is designed to automatically resolve some of these conflicts by merging the changes from multiple mods into a single patch mod. However, there are some limitations to what the Mod Merger can do:
- The Mod Merger can only merge changes that are not structurally conflicting on the same object.
- e.g., if two mods add properties to the same building, the Mod Merger can merge those changes together. But if one mod deletes some properties of the building, while another mod modifies those properties, the Mod Merger will report a conflict that requires manual resolution.
- The Mod Merger may not be able to resolve conflicts that involve complex logic or interactions between different objects. In such cases, manual review and editing may be necessary to ensure that the merged mod functions correctly.
- The Mod Merger currently not support merging of certain types of script files, such as event, inline scripts, on_actions, economic_plans etc. These files do not define top-level objects.
- Currently the merge conflict print is not very user-friendly.
Important modules
- Entry & config: synthetipy.script_merger.interface (BatchMerger, EXAMPLE_CONFIG)
- Merge core: synthetipy.script_merger.merge
- Matching & hashing: synthetipy.script_merger.matcher, gumtree_hash
- Edit & ops: synthetipy.script_merger.edits, ops
- Utilities: synthetipy.script_merger.utils
Notes
- Ensure GAME_FOLDER points to your Stellaris installation when needed.
- Merge outputs include generated edits and merged files; review before publishing.
- To change merge behavior, update interface configuration and relevant modules.
Modding in Python
(On going work...)
Generate PDX Script into python code, allowing modders to write mods in Python and compile them backto PDX Script.
Contributing
- Add tests for new features or bug fixes and submit a PR.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
synthetipy-0.1.0.tar.gz
(887.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
synthetipy-0.1.0-py3-none-any.whl
(917.1 kB
view details)
File details
Details for the file synthetipy-0.1.0.tar.gz.
File metadata
- Download URL: synthetipy-0.1.0.tar.gz
- Upload date:
- Size: 887.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a8b3e356a7cff692953bb9ba6da6f9144ad90488443f744fe9c3e97a47f7d59
|
|
| MD5 |
476da527dfdde11e3b187224efe76ac7
|
|
| BLAKE2b-256 |
21a65f5ed8b4977e2cfd3522d9d17a7a3f4191651307d3eb16ab65895f2d8468
|
File details
Details for the file synthetipy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: synthetipy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 917.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
725c9bcfcb02038fad76cc796ef0c63b687bd754cf012bf7bc610ea9afbd8be6
|
|
| MD5 |
0653c7c907c5cc89911fec97a8556116
|
|
| BLAKE2b-256 |
4a1dcb0ee5e8a44a0ced227305095a01188944e96b7ce198eb1e2b43a0a88621
|