CWTools is a library that provides common language services for paradox scripting files. This can be used to provide live validation of mod files as you are writing them. This is currently done through an extension for the text editor VS Code.
Current features are for Imperator, Stellaris, and Europa Universalis IV:
These all happen near-instantly as you're writing, just take a look at the examples below.
Validation errors/Feedback
The validation rules that make CW Tools work aren't perfect, but are open to contribution from the community. If you think you've found an incorrect error (something that works in vanilla but errors in CW Tools) or have other feedback/suggestions, you can:
1. Post them here, but please provide a complete example
2. PM either @Urist_McDorf or @Dayshine
3. Have a try at fixing it yourself (Get in touch for details, it's really easy)
Contributors:
The initial set of rules that made this all possible were written almost entirely by @Urist_McDorf , and we'll try to acknowledge everyone who contributes here.
- Urist_McDorf
- ngppgn
Installation:
Configuration:
Updates:
To update the extension go to the extensions tab, hit the three dots, and press "Check for updates". Then press the update button that appears next to the extension. Alternatively just turn on auto-updating extensions.
Roadmap
This doesn't include the addition of extra individual validators, but the overall key features.
0.9 (In progress)
* Full support for CK2/HOI4
0.8 (DONE)
* Full support for Imperator
0.7 (DONE)
* Full support for EU4
0.6 (DONE)
* Basic syntax validation for EU4, HOI4.
0.5 (DONE)
* Tailored trigger/effect checking (e.g. check "who" in effects)
* Performance improvements, reduce startup time
0.4 (DONE)
* Basic effect/trigger/modifier support for all files
* Selective disabling of warnings
* Dependent revalidation (e.g. if you change the localisation file, recheck all files)
0.3 (DONE)
* Full localisation validation (of all required implicit and explicit keys)
Acknowledgements
Thanks to Jamie550 for getting me started.
Also thanks to Caligula, blackninja9939, the ExO team, the Paradoxial Development Group and many others for their patience with my neverending questions.
Current features are for Imperator, Stellaris, and Europa Universalis IV:
- Immediate highlighting of syntax errors
- Autocomplete everywhere, providing appropriate dynamically generated options and descriptions when available
- Community supported rule based validation.
- A wide range of validators for common, interface, and events, checking
- That required localisation keys are defined
- Existence of effects/triggers/modifiers
- Scope context for used effects/triggers/modifiers
- Usage of scripted effects/triggers
- Correct entries for weights/AI_chance/etc
- That event\_targets are saved before they're used
- Check all "@" variables are defined before they're used
- and a number of other specific validators
- "Code actions" to generate .yml for missing localisation
- Tooltips providing localisation info, effect documentation as well as scope information
- A range of settings that allow you to customize what errors you see to fit your use
These all happen near-instantly as you're writing, just take a look at the examples below.
Validate syntax
Check for correct scopes
Find missing localisation
Tooltips for effects
See all your errors in a nice convenient summary
Check for correct scopes
Find missing localisation
Tooltips for effects
See all your errors in a nice convenient summary
The validation rules that make CW Tools work aren't perfect, but are open to contribution from the community. If you think you've found an incorrect error (something that works in vanilla but errors in CW Tools) or have other feedback/suggestions, you can:
1. Post them here, but please provide a complete example
2. PM either @Urist_McDorf or @Dayshine
3. Have a try at fixing it yourself (Get in touch for details, it's really easy)
Contributors:
The initial set of rules that made this all possible were written almost entirely by @Urist_McDorf , and we'll try to acknowledge everyone who contributes here.
- Urist_McDorf
- ngppgn
Installation:
- Install VS Code from https://code.visualstudio.com/docs/setup/setup-overview
- Go to the extensions tab and search for "cwtools" (or go to https://marketplace.visualstudio.com/items?itemName=tboby.cwtools-vscode and press "install".
- Wait for it to install and "Reload".
- Open your mod folder directly, or open your Imperator folder in "Documents/Paradox Interactive".
- Select your vanilla installation folder when prompted (On windows this would be "Steam\steamapps\common\ImperatorRome")
- Start editing to get syntax validation immediately
- Wait up to a minute for the full analysis to kick in (First time will take a little longer).
- Take a look at configuration below for available settings.
Configuration:
The tool currently has the follow settings you can change:
To change these:
1. File, Preferences, Settings (or Ctrl-comma)
2. Search for "cwtools"
3. Change the settings using the UI
4. Or press "edit in json" then press the pencil icon on the left to modify a setting, and edit them on the right
5. The changes should immediately take effect
Code:
// The location of a vanilla EU4 installation
"cwtools.cache.eu4": "",
// The location of a vanilla HOI4 installation
"cwtools.cache.hoi4": "",
// The location of a vanilla Stellaris installation
"cwtools.cache.stellaris": "",
// The location of a vanilla Imperator installation
"cwtools.cache.imperator": "",
// Error codes to ignore, list of IDs (e.g. "CW100" for syntax errors)
"cwtools.errors.ignore": [ "CW100" ],
// Files to ignore errors from, list of file names
"cwtools.errors.ignorefiles": [
"README.txt",
"credits.txt",
"credits_l_simp_chinese.txt",
"reference.txt",
"startup_info.txt"
],
// Whether or not to show errors for vanilla files
"cwtools.errors.vanilla": "false",
// Whether or not to enable experimental features
"cwtools.experimental": "false",
// The list of languages to validate localisation for.
"cwtools.localisation.languages": [
"English", "German"
],
// A folder containing custom rules to use
"cwtools.rules_folder": "",
// Which version of rules to auto-update to. Manual will use the local path set in rules_folder
// Stable is recommended intially, but latest is updated frequently
"cwtools.rules_version": "stable"
To change these:
1. File, Preferences, Settings (or Ctrl-comma)
2. Search for "cwtools"
3. Change the settings using the UI
4. Or press "edit in json" then press the pencil icon on the left to modify a setting, and edit them on the right
5. The changes should immediately take effect
Updates:
To update the extension go to the extensions tab, hit the three dots, and press "Check for updates". Then press the update button that appears next to the extension. Alternatively just turn on auto-updating extensions.
Planned (Current)
* Variables: Check variables are used in consistent scopes (if you set on a planet, you can only check on a planet)
* IDE: Contextual autocompletion, only show relevant keywords not all of them!
* Dead code detection (e.g. find events that are never called)
* Localisation: Scripted locs
* Localisation: Check correct scope for localisation keys
Future
* Localisation: Support custom localisations (e.g. mandarin)
* Variables: Unused by defined variables
* Syntax: Find multiple syntax errors in the same file
Blue skies
*
Completed
* Common: Check all effects/triggers/scopes in all files, not just events.
* Defines: Check defines overriden by mods exist in vanilla
* Effects/Triggers: Intelligently calculate scope for *recursive* effects/triggers
* Events: event_target is not defined but is used in effect/trigger
* IDE: Autocompletion
* Localisation: Check "default" language, i.e. localisation_synced
* Localisation: $keys$
* Localisation: Special command validator (the keywords in localisation strings)
* Localisation: Check validation file names
* Modifiers: Check existence of modifiers in common files (buildings, etc).
* Modifiers: Check correct scope usage of modifiers in common files (buildings, etc).
* Modifiers: Derive modifiers from ship sizes
* Variables: Check that variables have been defined somewhere
* Deal with file overwriting with multiple mods
* Variables: Check variables are used in consistent scopes (if you set on a planet, you can only check on a planet)
* IDE: Contextual autocompletion, only show relevant keywords not all of them!
* Dead code detection (e.g. find events that are never called)
* Localisation: Scripted locs
* Localisation: Check correct scope for localisation keys
Future
* Localisation: Support custom localisations (e.g. mandarin)
* Variables: Unused by defined variables
* Syntax: Find multiple syntax errors in the same file
Blue skies
*
Completed
* Common: Check all effects/triggers/scopes in all files, not just events.
* Defines: Check defines overriden by mods exist in vanilla
* Effects/Triggers: Intelligently calculate scope for *recursive* effects/triggers
* Events: event_target is not defined but is used in effect/trigger
* IDE: Autocompletion
* Localisation: Check "default" language, i.e. localisation_synced
* Localisation: $keys$
* Localisation: Special command validator (the keywords in localisation strings)
* Localisation: Check validation file names
* Modifiers: Check existence of modifiers in common files (buildings, etc).
* Modifiers: Check correct scope usage of modifiers in common files (buildings, etc).
* Modifiers: Derive modifiers from ship sizes
* Variables: Check that variables have been defined somewhere
* Deal with file overwriting with multiple mods
Roadmap
This doesn't include the addition of extra individual validators, but the overall key features.
0.9 (In progress)
* Full support for CK2/HOI4
0.8 (DONE)
* Full support for Imperator
0.7 (DONE)
* Full support for EU4
0.6 (DONE)
* Basic syntax validation for EU4, HOI4.
0.5 (DONE)
* Tailored trigger/effect checking (e.g. check "who" in effects)
* Performance improvements, reduce startup time
0.4 (DONE)
* Basic effect/trigger/modifier support for all files
* Selective disabling of warnings
* Dependent revalidation (e.g. if you change the localisation file, recheck all files)
0.3 (DONE)
* Full localisation validation (of all required implicit and explicit keys)
Acknowledgements
Thanks to Jamie550 for getting me started.
Also thanks to Caligula, blackninja9939, the ExO team, the Paradoxial Development Group and many others for their patience with my neverending questions.
Last edited:
- 2
- 1
- 1