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 Stellaris and EU4:
These all happen near-instantly as you're writing, just take a look at the examples below.
Tips:
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 @Dayshine
3. Have a try at fixing it yourself (Get in touch with me for details, it's really easy)
Contributors:
The initial set of rules that made this all possible were a collaboration of modders from the Stellaris modding den, and we'll try to acknowledge everyone who contributes here.
- ExNihil
- Dayshine
- Caligula Caeser
- had
- Iyur
- ViolentBeetle
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.
If you have suggestions for extra validation errors, warnings, or hints, please post them here.
Roadmap
This doesn't include the addition of extra individual validators, but the overall key features.
0.8 (In progress)
* Full support for CK2/HOI4
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 Stellaris and EU4:
- 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
- That referenced sprites and graphics files exist
- 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.
![8UZDaFL.gif](https://i.imgur.com/8UZDaFL.gif)
Validate syntax
Check for correct scopes
Find missing localisation
Tooltips for effects
See all your errors in a nice convenient summary
![VWRXtT7.gif](https://i.imgur.com/VWRXtT7.gif)
Check for correct scopes
![EPb4XSL.gif](https://i.imgur.com/EPb4XSL.gif)
Find missing localisation
![pzZ8Z22.gif](https://i.imgur.com/pzZ8Z22.gif)
Tooltips for effects
![qeyMSyo.gif](https://i.imgur.com/qeyMSyo.gif)
See all your errors in a nice convenient summary
![IaqoFgF.png](https://i.imgur.com/IaqoFgF.png)
- You can type "error", "warning" or "info" into the search box in the problems panel to filter.
- If you don't like a specific diagnostic, you can use the setting "cwtools.errors.ignore" to hide it
- By default only English localisation is checked. Use "cwtools.localisation.languages" to check others.
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 @Dayshine
3. Have a try at fixing it yourself (Get in touch with me for details, it's really easy)
Contributors:
The initial set of rules that made this all possible were a collaboration of modders from the Stellaris modding den, and we'll try to acknowledge everyone who contributes here.
- ExNihil
- Dayshine
- Caligula Caeser
- had
- Iyur
- ViolentBeetle
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 Stellaris folder in "Documents/Paradox Interactive".
- Start editing to get syntax validation immediately
- Wait up to a minute for the full analysis to kick in.
- Take a look at configuration below for available settings.
- Optionally, install the syntax highlighting extension https://marketplace.visualstudio.com/items?itemName=tboby.paradox-syntax
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. Press the pencil icon on the left to modify a setting, and edit them on the right
4. The changes should immediately take effect
Code:
// Error codes to ignore, list of IDs (e.g. "CW100" for syntax errors)
"cwtools.errors.ignore": [ "CW100" ],
// 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"
],
// Traces the communication between VSCode and the language server.
"cwtools.trace.server": "off",
//Files to ignore error from, list of file names
"cwtools.errors.ignorefiles": "README.txt,credits.txt,credits_l_simp_chinese.txt,reference.txt,startup_info.txt"
To change these:
1. File, Preferences, Settings (or Ctrl-comma)
2. Search for "cwtools"
3. Press the pencil icon on the left to modify a setting, and edit them on the right
4. 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.
If you have suggestions for extra validation errors, warnings, or hints, please post them here.
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
* Events: (title, desc, picture, location, show_sound, diplomatic, picture_event_data) + hide_window doesn't make sense
* Events: is_triggered_only = yes and never called
* Performance: never use any_planet or every_system_planet if you are not in system scope
* Localisation: Support custom localisations (e.g. mandarin)
* Localisation: Check validation file names
* Localisation: Reduced false-positives for static modifiers
* Events: This trigger should be a pretrigger
* Variables: Unused by defined variables
* Syntax: Find multiple syntax errors in the same file
* Common: Building tags/component tags need whitespace above/below
* Localisation: Building tags/component tags
* Defines: Check defines overriden by mods exist in vanilla
Blue skies
*
Completed
* Common: Check all effects/triggers/scopes in all files, not just events.
* Effects/Triggers: Intelligently calculate scope for *recursive* effects/triggers
* Events: event_target is not defined but is used in effect/trigger
* IDE: Autocompletion
* Localisation: traditions, buildings, aura components, component templates
* Localisation: Static modifiers
* Localisation: Check names inside event effects (create_ship `name`)
* Localisation: Check "default" language, i.e. localisation_synced
* Localisation: $keys$
* Localisation: Special command validator (the keywords in localisation strings)
* 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
* Events: (title, desc, picture, location, show_sound, diplomatic, picture_event_data) + hide_window doesn't make sense
* Events: is_triggered_only = yes and never called
* Performance: never use any_planet or every_system_planet if you are not in system scope
* Localisation: Support custom localisations (e.g. mandarin)
* Localisation: Check validation file names
* Localisation: Reduced false-positives for static modifiers
* Events: This trigger should be a pretrigger
* Variables: Unused by defined variables
* Syntax: Find multiple syntax errors in the same file
* Common: Building tags/component tags need whitespace above/below
* Localisation: Building tags/component tags
* Defines: Check defines overriden by mods exist in vanilla
Blue skies
*
Completed
* Common: Check all effects/triggers/scopes in all files, not just events.
* Effects/Triggers: Intelligently calculate scope for *recursive* effects/triggers
* Events: event_target is not defined but is used in effect/trigger
* IDE: Autocompletion
* Localisation: traditions, buildings, aura components, component templates
* Localisation: Static modifiers
* Localisation: Check names inside event effects (create_ship `name`)
* Localisation: Check "default" language, i.e. localisation_synced
* Localisation: $keys$
* Localisation: Special command validator (the keywords in localisation strings)
* 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.8 (In progress)
* Full support for CK2/HOI4
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:
- 6