https://github.com/cwtools/cwtools
A library for parsing, editing, and validating Paradox Interactive script files.
https://github.com/cwtools/cwtools
crusaders-kings-2 europa-universalis-4 hearts-of-iron-4 paradox paradox-interactive stellaris
Last synced: 3 months ago
JSON representation
A library for parsing, editing, and validating Paradox Interactive script files.
- Host: GitHub
- URL: https://github.com/cwtools/cwtools
- Owner: cwtools
- License: mit
- Created: 2017-10-30T21:52:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-10-04T10:56:34.000Z (4 months ago)
- Last Synced: 2025-10-04T12:29:21.489Z (4 months ago)
- Topics: crusaders-kings-2, europa-universalis-4, hearts-of-iron-4, paradox, paradox-interactive, stellaris
- Language: F#
- Homepage: https://cwtools.github.io/
- Size: 69.4 MB
- Stars: 125
- Watchers: 13
- Forks: 32
- Open Issues: 43
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cwtools 
A library for parsing, editing, and validating Paradox Interactive script files.
Supports all modern Paradox Interactive games, and targets .net standard 2.0.
Considering contributing? [Start here!](https://github.com/tboby/cwtools/wiki/Contributing)
## Projects that use CW Tools
#### [Stellaris tech tree](http://www.draconas.co.uk/stellaristech): https://github.com/draconas1/stellaris-tech-tree
An interactive tech tree visualiser that uses CW Tools to parse the vanilla tech files, and extract localisation.
#### [SC Mod Manager](https://github.com/WojciechKrysiak/SCModManager): https://github.com/WojciechKrysiak/SCModManager/tree/feature/PortToAvalonia/PDXModLib/Utility
A mod manager that uses CW Tools for parsing and manipulating mod files.
## Example usage (C#)
This is a simple example of loading an event file, modifying it, and printing the updated events.
```csharp
//Support UTF-8
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
//Parse event file
var parsed = CWTools.Parser.CKParser.parseEventFile("./testevent.txt");
var eventFile = parsed.GetResult();
//"Process" result into nicer format
var processed = CK2Process.processEventFile(eventFile);
//Find interesting event
var myEvent = processed.Events.FirstOrDefault(x => x.ID == "test.1");
//Add is_triggered_only = true
var leaf = new Leaf("is_triggered_only", Value.NewBool(true));
myEvent.AllChildren.Add(Child.NewLeafC(leaf));
// or
myEvent.AllChildren.Add(Leaf.Create("is_triggered_only", Value.NewBool(true)));
//Output
var output = processed.ToRaw;
Console.WriteLine(CKPrinter.printKeyValueList(output, 0));
```
Which will take a file like
```
namespace = test
#One event
country_event = {
id = test.1
desc = "test description"
}
#Another event
country_event = {
id = test.2
desc = "test 2 description"
}
```
and output a file like
```
namespace = test
#One event
country_event = {
is_triggered_only = yes
id = test.1
desc = "test description"
}
#Another event
country_event = {
id = test.2
desc = "test 2 description"
}
```