-
Notifications
You must be signed in to change notification settings - Fork 31
Contributing
Thanks for considering contributing to cwtools! Depending on your familiarity with Paradox modding, cwtools and F#, you might want to take different approaches to getting started. This guide is intended to suggest what those routes might be.
My first recommendation is to try using the main consumer of the cwtools library, VS Code's cwtools-vscode extension.
- Have you used the cwtools extension for VS Code?
- Yes: Skip to 4
- No: Install it from here then continue to 2
- Are you familiar with Paradox modding?
- Yes: Following the instructions on the extension page to point this at your mod, have a play, then continue to 4
- No: The scripting language used by Paradox games is less of a programming language and more of a data structure. It is comparable to writing complicated logic using
.yml
or JSON. This wiki page provides a reasonable overview and might be helpful as a glossary. Continue to 3
- Do you own a copy of a modern Paradox game (EU4, Stellaris, CK2, HOI4, Imperator)? Try downloading the suggested mod:
- HOI4: https://github.com/EaW-Team/equestria_dev
- Stellaris: https://github.com/MoreEventsMod/More_Events_Mod_Beta
- No:
- Create a folder called "Hearts of Iron IV" somewhere (e.g.
D:\Temp\Hearts of Iron IV
) - Download the
equestria_dev
mod above and extract it below that folder (D:\Temp\Hearts of Iron IV\equestria_dev
) - Open VS Code, and "Open folder" on
equestria_dev
. - Open a file in the
events
folder. - Dismiss the prompts to select a vanilla installation directory (things will break, but not too much).
- Create a folder called "Hearts of Iron IV" somewhere (e.g.
You should place the mod in your user mod folder if you have one: C:\Users\<your_username>\Documents\Paradox Interactive\<game name>\mod\<mod folder>
.
Then, open VS Code, open that mod folder, then open a .txt
file (I recommend an "event" file in the "events" folder).
- CWTools implements the Language server protocol. Have a look at the spec and try out the different features (event files are a good place to experiment). I link to the specification, but VS Code provides a useful visual guide here.
- Diagnostics: Try generating errors by mangling syntax, changing LHS keys randomly, or changing RHS values to be out of range.
-
Completion: Trigger completion using
ctrl-space
. See how it is limited to context relevant values, and sorted roughly by usage. -
Hover: Hover over a few random elements.
country_event
or similar should show you the related localisation keys.is_neighbour_of
or similar triggers should show you usage information as well as some context. -
Go to definition: Find a line like
country_event = { id = my_event.5 }
and press F12 onmy_event.5
. See how it takes you to the definition - Outline: Open the explorer panel on the left and view the "Outline" section to see defined symbols in this document.
-
Actions: Change the RHS value of a
title
,description
orname
field so that you get aCW100
missing localisation error. Click in the error text and see the "lightbulb" appear. Select a "generate localisation .yml" option in that menu.
If you're familiar with C#/.NET: F# is just another language that uses the same libraries and is completely compatible.
If you're familiar with Haskell/ML/etc: F# is an impure and more pragmatic functional language (sometimes mutable state is really handy for performance).
For others: It's just another programming language :)
Resources:
- An excellent resource for non-functional programmers: https://fsharpforfunandprofit.com/
- A wikibook, it's pretty good for some small examples, but not complete: https://en.wikibooks.org/wiki/F_Sharp_Programming
- The official docs are good: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/
- A lot deeper, but the closest to official standards for design: https://fsharp.org/specs/component-design-guidelines/
- If you prefer a video: It's not enough itself but gives you an idea about similarities and differences between C# and F#. https://www.youtube.com/watch?v=KPa8Yw_Navk
See Build and Run for getting set up
The following articles go into more details on various aspects of cwtools:
- Overview of the main namespace.
- Validation config format guidance
- Testing