Giter Club home page Giter Club logo

cwtools's Introduction

cwtools nuget

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!

Projects that use CW Tools

An interactive tech tree visualiser that uses CW Tools to parse the vanilla tech files, and extract localisation.

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.

            //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"
         }

cwtools's People

Contributors

b0urb4k1 avatar blind-striker avatar herrx2000 avatar kimotoyanke avatar maxice8 avatar ramit110 avatar tboby avatar tbobyox avatar uristmcdorf avatar wojciechkrysiak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cwtools's Issues

Parsing issues in Vic3

I've encountered at least two parsing issues with CWTools and Vic3.

  1. In the CoA files, certain formulas use parentheses such as line 6 of 02_countries.txt @canton_scale_cross_x = @[ ( 333 / 768 ) + 0.001 ]. This gives the following error:
Error in d:\Installed Programs\Steam\steamapps\common\Victoria
3\game\common\coat_of_arms\coat_of_arms\02_countries.txt: Ln: 6 Col: 28
@canton_scale_cross_x = @[ ( 333 / 768 ) + 0.001 ]
                           ^
Expecting: end of input or statement
  1. Named colors can use either int or float values, depending on colorspace type, but float values, using the decimal gives the following error:
Error in d:\Installed Programs\Steam\steamapps\common\Victoria
3\game\common\named_colors\00_coa_colors.txt: Ln: 2 Col: 32 (UTF16-Col: 25)
        todo_purple = rgb { 1 0.4 0.6 }
                               ^
Note: The column count assumes a tab stop distance of 8 chars.
Unknown Error(s)

Rules wishlist

To not create an issue for every single functionality request.

  • Uniqueness rule - a rule that ensures that all used LHSes of a token with a mutable LHS (, enum[], variables) are unique. Shouldn't interfere with cardinality, so if you use ## unique ## cardinality = 4..4 <type> = blah it should ensure that exactly four different keys of <type> are used.
  • ## cardinality = all - a rule that ensures that for a token with a <type> or enum[] LHS all defined variants of that type/enum are used. For example, if you have a <type> with type1 and type2 defined and the rule is ## cardinality = all <type> = blah anything other than type1 = blah type2 = blah should be an error.
  • Scope docs - so that instead of writing Blah blah. ROOT is the attacker, FROM is the defender. in the block proper we can display that info in the scope viewer tooltip. ## scope_docs = { THIS = "Blah blah" ROOT = "Blah blah" }?
  • Ensured type keys - a way to ensure that types of specific keys exist, for hardcoded and dynamic modifiers. Will probably have to take replace_path in the .mod file into account somehow, though.
  • In-mod docs - use ### text at the top of a key definition as custom documentation for the key. Would be especially useful for modifiers as apart from the docs themselves the modders could list what scopes they're used in. So for example ### Scopes: character <br> modifier1 = { ... } would show "Scopes: character" as a doc tooltip when selecting modifier1 in a field that accepts it or hovering over it.
  • Proper switch - instead of just using scalar.
  • Autogenerated docs export - based on the same ### syntax, maybe a bit expanded, export event, scripted_x, etc descriptions to .md files for easy viewing.
  • Autocomplete types - like with other blocks, autocomplete newly created instances of a type. Probably not going to work with all of them due to nested types and stuff, but better than nothing.
  • skip_root_key logic - OR and NOR operators, at least. In CKII, the former is needed for laws, the latter for alternate_start.
  • Top type replacement - a rule for properties in nested types that makes the tooltip say what value the top-level type's same-name property has for you to overwrite and warns if you're overwriting it with the same value.
  • Sprite frame rule - something like LHS = int[sprite_with_frames_name] which ensures the int stays within the bounds of 1..sprite_with_frames_name:noOfFrames. Must also ensure that sprite_with_frames_name has noOfFrames in the first place.
  • Sprite tooltips - hovering over a sprite's name should show its contents in the tooltip. Hovering over an int when that int's source is a sprite with frames (see Sprite frame rule) should show that specific frame.
  • Colour tooltips and decorators - hovering over a colour should show a colour picker in the tooltip. Colours should show decorators next to them.
  • Defines - defines set in a separate text file in the mod's root, to be used in the rules in the configs, so that modders that change UI or other things can adjust the defines accordingly without going down to the configs.
  • Variables from code - if possible; as Defines but using the mod's own values (either the value of a property in the type, or the value of a define).
  • Loc key injection for parent type - an $$ variable to be used to refer to the parent type's name when defining loc for a nested type. In CKII needed for alternate start options.
  • Single alias body - for copying bundles of tokens without necessiating an LHS-RHS relationship so you can mix in some unique tokens in there as well.

RAM usage

Is the high ram usage normal? Or rather why does CW tools load everything into RAM?
Unbenannt

How long until next support?

Hello there :)

Since 1.30 has been released I've been having some troubles with the extension setting.

Every setting was as before, but I just can't have any more autocompletion or error checking.
When tried to reload the extension I get the
loading project...
but nothing more
2020 06 10-09 35

Is there something I can do to try to force the new game version? or should I just wait for the next extension setting?

thanks in advance,
have a nice day :)

[BUG] Memory Consumption

Due to recent updates to CWtools, memory consumption in VSC is in the GB on larger projects. Some of my developers have been seeing large spikes in memory in the past month where they hadn't before. Reverting back to the following version, v0.10.12, from v0.10.17, seems to help minimize the issue.

image

Program doesn't initialize, seemingly randomly

Title is self explanatory. I will reload the window over and over and over and nothing initializes and I receive a There is no data provider registered that can provide view data. message in the CWTOOLS LOADED FILES, but then, seemingly out of nowhere, it initializes and works fine all day after that?

Not sure what I can do to prevent this but it can be quite a setback.

If there's anything I can provide to help with troubleshooting please let me know!

How to load dependences

My mod has a dependence, and it is stated correctly in the .mod file. However, CWTools doesn't load that base mod at all. If would be great if CWTools could lode mod dependencies as well. Right now there is so many false alerts and that's annoying.

HOI4 support

Needed:

  • List of all scopes
  • List of all scope commands (and supported source scopes, excluding anything in trigger docs)
  • trigger_docs (does it exist for HOI4? Is it same format?)
  • Modifier info (does setup.log list them?)
  • Modifier categories
  • datatype, does HOI4 PDXscript have anything extra?

Build on Mono/Linux

Hi there! I'm trying to set up some CI for a HOI4 mod and would like to use this library if possible; however, I'm having a hard time getting it to build on Linux. It looks like the build is trying to invoke a RunFsc.sh file that doesn't exist; I can't find the .cmd version either.

Any pointers?

Below is the snippet of the actual Build target; process was invoked with ./build.sh.

Starting Target: Build (==> Restore)
dotnet build
Microsoft (R) Build Engine version 16.0.225-preview+g5ebeba52a1 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Paket version 5.194.3
  The last restore is still up to date. Nothing left to do.
  Performance:
   - Runtime: 76 milliseconds
/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'FSharpx.Collections 1.17.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'Newtonsoft.Json.FSharp 3.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'NodaTime 1.4.5' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
  Restore completed in 45.88 ms for /home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj.
/home/wtchappell/ws/cli/artifacts/tmp/Debug/dotnet/sdk/3.0.100-preview-009752/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(142,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj]
  Paket version 5.194.3
  The last restore is still up to date. Nothing left to do.
  Performance:
   - Runtime: 81 milliseconds
/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'FSharpx.Collections 1.17.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'Newtonsoft.Json.FSharp 3.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'NodaTime 1.4.5' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
/home/wtchappell/ws/cwtools/CWTools/Common/Constants.fs(44,6): warning FS0346: The struct, record or union type 'Effect' has an explicit implementation of 'Object.Equals'. Consider implementing a matching override for 'Object.GetHashCode()' [/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj]
/home/wtchappell/ws/cwtools/CWTools/Common/Constants.fs(61,6): warning FS0346: The struct, record or union type 'ScriptedEffect' has an explicit implementation of 'Object.Equals'. Consider implementing a matching override for 'Object.GetHashCode()' [/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj]
/home/wtchappell/ws/cwtools/CWTools/Common/Constants.fs(77,6): warning FS0346: The struct, record or union type 'DocEffect' has an explicit implementation of 'Object.Equals'. Consider implementing a matching override for 'Object.GetHashCode()' [/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj]
/home/wtchappell/ws/cli/artifacts/tmp/Debug/dotnet/sdk/3.0.100-preview-009752/FSharp/Microsoft.FSharp.Targets(265,9): error MSB6006: "RunFsc.sh" exited with code 139. [/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj]

Build FAILED.

/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'FSharpx.Collections 1.17.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'Newtonsoft.Json.FSharp 3.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'NodaTime 1.4.5' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'FSharpx.Collections 1.17.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'Newtonsoft.Json.FSharp 3.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj : warning NU1701: Package 'NodaTime 1.4.5' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
/home/wtchappell/ws/cwtools/CWTools/Common/Constants.fs(44,6): warning FS0346: The struct, record or union type 'Effect' has an explicit implementation of 'Object.Equals'. Consider implementing a matching override for 'Object.GetHashCode()' [/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj]
/home/wtchappell/ws/cwtools/CWTools/Common/Constants.fs(61,6): warning FS0346: The struct, record or union type 'ScriptedEffect' has an explicit implementation of 'Object.Equals'. Consider implementing a matching override for 'Object.GetHashCode()' [/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj]
/home/wtchappell/ws/cwtools/CWTools/Common/Constants.fs(77,6): warning FS0346: The struct, record or union type 'DocEffect' has an explicit implementation of 'Object.Equals'. Consider implementing a matching override for 'Object.GetHashCode()' [/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj]
/home/wtchappell/ws/cli/artifacts/tmp/Debug/dotnet/sdk/3.0.100-preview-009752/FSharp/Microsoft.FSharp.Targets(265,9): error MSB6006: "RunFsc.sh" exited with code 139. [/home/wtchappell/ws/cwtools/CWTools/CWTools.fsproj]
    9 Warning(s)
    1 Error(s)

Time Elapsed 00:00:11.54
Running build failed.
Error:
System.Exception: dotnet build failed
  at [email protected] (System.String message) [0x00001] in <c7e4655799f4413aa9606b20e8831743>:0
  at FSI_0005.Build.runDotnet (System.String workingDir, System.String args) [0x00048] in <c7e4655799f4413aa9606b20e8831743>:0
  at [email protected] (System.String p) [0x0000a] in <c7e4655799f4413aa9606b20e8831743>:0
  at Microsoft.FSharp.Collections.SeqModule.Iterate[T] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] action, System.Collections.Generic.IEnumerable`1[T] source) [0x0002d] in <5893d081904cf4daa745038381d09358>:0
  at [email protected] (Microsoft.FSharp.Core.Unit _arg3) [0x0000b] in <c7e4655799f4413aa9606b20e8831743>:0
  at Fake.TargetHelper.runSingleTarget (Fake.TargetHelper+TargetTemplate`1[a] target) [0x00049] in <5ae96a91ccf1c534a7450383916ae95a>:0

---------------------------------------------------------------------
Build Time Report
---------------------------------------------------------------------
Target     Duration
------     --------
Clean      00:00:09.9402610
Restore    00:00:04.9642390
Build      Failure
Total:     00:00:28.9605720
---------------------------------------------------------------------
Status:    Failure
---------------------------------------------------------------------
---------------------------------------------------------------------
  1) System.Exception: dotnet build failed
  at [email protected] (System.String message) [0x00001] in <c7e4655799f4413aa9606b20e8831743>:0
  at FSI_0005.Build.runDotnet (System.String workingDir, System.String args) [0x00048] in <c7e4655799f4413aa9606b20e8831743>:0
  at [email protected] (System.String p) [0x0000a] in <c7e4655799f4413aa9606b20e8831743>:0
  at Microsoft.FSharp.Collections.SeqModule.Iterate[T] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] action, System.Collections.Generic.IEnumerable`1[T] source) [0x0002d] in <5893d081904cf4daa745038381d09358>:0
  at [email protected] (Microsoft.FSharp.Core.Unit _arg3) [0x0000b] in <c7e4655799f4413aa9606b20e8831743>:0
  at Fake.TargetHelper.runSingleTarget (Fake.TargetHelper+TargetTemplate`1[a] target) [0x00049] in <5ae96a91ccf1c534a7450383916ae95a>:0
---------------------------------------------------------------------

>>> elapsed time 34s

Referencing trouble

Type 'CharParsers.ParcerResult<,>' is defined in an assembly that is not referenced
image
VS quick actions do nothing. Got cwtools with NuGet

How to update the new keys added of EU4 mod?

I'm using CWTools for EU4 modding, but I find that CWTools never loaded keys in my mod. For example, I added a new tag XXX, but CWTools still tells me "Expecting a country_tags value" when I use "tag = XXX". It also warns me for localisations and sends error for me when I use global flags, new religions etc. Even though I created them in my mod.
WHY DID CWTools NEVER READ MY MOD's NEW DECLARATIONS?

By the way, it's said that "tree view cwtools-files never registered", and I don't know how to do with this.

Issue With Arithmetic Parsing in Stellaris

I'm currently using a Stellaris Ascension Perks modifier that throws an error on parsing from CWTools. It looks as follows:
modifier = { weapon_archaeotech_weapon_damage_mult = @[ 0.33 - ( 0.06 * sartek_acg_mod_active ) ] }
This modifier is valid, I've tested in-game and it works exactly as written. 0.27 when the variable is inactive, 0.33 when the variable is active. When using the CWTools parser from Irony Mod Manager, I get the following error:
IronyModManager_WE2PvP3aV5
The file with the modifier is provided below as a reference.
~z_sartek_ascmgr_perks.txt

CK2 keep getting CW113 (file not found) if using "\\" in path

Hi, there is a problem with the paths

Problem

image

I looked at the validators code, "\\" is replaced with "/" everywhere, but the error is still popping up for some reason.

Possible cause

I have zero experience with C#, F#, but from my JS and Go experience, I think that the reason is that you replace just "\\", the virtual machine turns it into "\", because the first backslash just escapes the second

Possible solution

As I read here and here, if you add @ to your string you want to replace, the virtual machine will not turn double backslash into a single, and it will properly replace them to single normal slash

So you need something like:

let file = leaf.ValueText.Trim('"').Replace(@"\\","/").Replace(".lua",".shader").Replace(".tga",".dds")

Can't modify nodes using C#?

Hello,

Thank you for developing this tool.

I'm trying to use cwtools to programmatically edit Clausewitz files.

Running the tests in CWToolsCSTests, I've noticed that the tests fail to modify the leaves.

            //Parse event file
            // var parsed = CWTools.Parser.CKParser.parseEventFile("./testevent.txt");
            var text = File.ReadAllText("./testevent.txt");
            var parsed = CWTools.CSharp.Parsers.ParseScriptFile("testevent.txt", text);

            var eventFile = parsed.GetResult();

            //"Process" result into nicer format
            // var processed = CK2Process.processEventFile(eventFile);
            var processed = CWTools.CSharp.Parsers.ProcessStatements("testevent.txt", "./testevent.txt", eventFile);

            //Find interesting event
            var myEvent = processed.Nodes.FirstOrDefault(x => x.TagText("id") == "test.1");

            //Add is_triggered_only = true
            var leaf = new Leaf(KeyValueItem.NewKeyValueItem(Key.NewKey("is_triggered_only"), Value.NewBool(true), Operator.Equals), FSharpOption<range>.None);
            myEvent.AllChildren.Add(Child.NewLeafC(leaf));

The last line results in a no-op, as the list refuses to be modified and C# won't tell me why. Any ideas on how to circumvent this?

CK2DNA validation

Problem

As it said in the wiki, CK2 dna is an alphaNUMERICAL code, meaning

image

But CWTools actually requires every symbol of dna to be a letter

| ValueType.CK2DNA ->
if key.Length = 11 && key |> Seq.forall (Char.IsLetter)
then errors
else inv (ErrorCodes.ConfigRulesUnexpectedValue (sprintf "Expecting a dna value, got %s" key) severity) leafornode <&&&> errors

So we get errors in absolute valid alphanumerical dna:

image

Solution

Just replace IsLetter to IsLetterOrDigit

 | ValueType.CK2DNA -> 
     if key.Length = 11 && key |> Seq.forall (Char.IsLetterOrDigit) 
     then errors 

targeted variables don't work with scopes

Probably related to cwtools/cwtools-hoi4-config#10
For example a variable in variable.cwt like ai_attitude_allied_weight@scope[country] doesn't work in something like
check_variable = { ai_attitude_allied_weight@ROOT > 1 }
instead it assumes that the variable is literally ai_attitude_allied_weight@scope[country]

It does work for types and enums

some_hard_coded_variable@enum[country_tags]
check_variable = { some_hard_coded_variable@TAG > 1 }

some_hard_coded_variable@<state>
check_variable = { some_hard_coded_variable@123 > 1 }

both work and give no error

Allow icon[file/path] to recurse into sub-directories

in EU4 the mission icons are stored in gfx/interface/missions, but not only in a flat structure, they have sub-directories, here is a snapshot of the structure as of 1.34.5.0 (only shows directories, each contains multiple .dds files)

$ tree -d gfx/interface/missions
gfx/interface/missions
└── dlc_missions
    ├── dharma
    │   ├── Bahmani
    │   ├── Bahrat-Hindustan
    │   ├── Bengal
    │   ├── Delhi
    │   ├── gujarati
    │   ├── malwa
    │   ├── menwar
    │   ├── mughal
    │   ├── Orissa
    │   ├── taungu
    │   └── vijayanagar
    ├── dlc_missions
    │   └── third_rome
    │       └── muscovy_russia
    ├── emperor
    │   ├── austria
    │   ├── bavaria
    │   ├── bohemia
    │   ├── brandenburg1
    │   ├── brandenburg2
    │   ├── burgundy
    │   ├── crusaders
    │   ├── florence
    │   ├── france1
    │   ├── france2
    │   ├── genoa
    │   ├── germany
    │   ├── hansa
    │   ├── hungary
    │   ├── italy
    │   ├── milan1
    │   ├── milan2
    │   ├── naples
    │   ├── netherlands
    │   ├── papal_state
    │   ├── provence
    │   ├── savoy
    │   ├── saxony
    │   ├── serbia
    │   ├── switzerland1
    │   ├── switzerland2
    │   ├── venice1
    │   └── venice2
    ├── gc
    │   ├── andalus
    │   ├── aragon
    │   ├── castile
    │   ├── granada
    │   ├── morocco
    │   ├── portugal
    │   └── tunis
    ├── leviathan
    ├── lions_of_the_north
    ├── origins
    ├── pf
    ├── rb
    └── third_rome
        ├── muscovy_russia
        ├── novgorod
        └── russian_minors

63 directories

Is it possible to have icon[] accept a subdirs argument ? like icon[gfx/interface/missions,subdirs].

Series of modifiers (and conditions) that are unexpected (whereas the game process it correctly)

Hello, I went through a serious of modifiers and conditions that are unexpected by the extension, whereas the game process it correctly, I will post only one photo to show you what I mean:
2020 07 12-01 41

  1. movement_speed_onto_off_boat_modifier
  2. accept_vassalization_reasons
  3. institution_growth
  4. extra_manpower_at_religious_war = yes (I recall this working, although I may be wrong)

Conditions:

  1. ADM/DIP/MIL (used to refer the current adm/dip/mil stat of the ruler)
  2. has_adm_advisor_1/2/3 as well as has_dip_advisor_1/2/3 and has_mil_advisor_1/2/3

Effects:

  1. join_all_offensive_wars_of = TAG
  2. join_all_defensive_wars_of = TAG

if I'll ever find others I'll write them down :)

Add new directories for CWT to recognize

Currently building a pet project HOI4 mod with a couple of friends; since I don't like having to deal with git and "Documents" folder Windows protection bashing heads, I set up my mod files elsewhere on my computer. Unfortunately this seems to be preventing CWTools from recognizing my mod folder properly. Is there any way to add additional directory locations to CWT's registered list of "places-to-look-for-mods"? Thanks a bunch in advance :)

political_leader_cost_factor unexpected?

In hoi4 files, Cwtools reports political_leader_cost_factor is unexpected token in any scopes.
but it certainly works in the game.
Can anyone fix this problem?

political_leader_cost_factor is unexpected in ROM_bratianu_leader CW262(CW262)

Adding a Child

idk if I'm doing something wrong or understanding it wrong, but when I use the example in CWToolsCSTests it wont add the child leaf to the node MyEvent

Missing Field of TypeField (Simple "mission.fixed"), expecting at least 1CW242(CW242) and related problem with missions.

So, I'm having a strange, and annoying bug with the tool
I simply loaded the usual files I'm working on it, and it gives me these problems on some missions
immagine

every mission that is highlighted in red make all the autocompletion not working there
and if a mission slot has at least one mission with the red underline, the whole slot does not work

this is the mission slot error
immagine

this is the mission error
immagine

if I tried to generate a mission, this would happen
immagine

If I would click on the first 7 option, it would load me a new mission correctly with the icon, required_missions, trigger, effect
immagine

but sadly if I try to create a custom mission, everything goes nuts

I want to say that this happened only on some files, not all of them.

one thing I noticed is that, in those files, I do not have the navigation as well:
immagine

Auto-indent breaking

I am unsure if this is a HOI4-specific issue or not, but I'll post it here for now. Quite frequently, auto-indent seems to break. I've checked with other people and they are encountering the same issue. The reason I think this is a CWTools issue and not general VS Code issue is because I think it's unlikely (although I admit still possible) that such an annoying bug persists for such a long time in a widely-used product like VS Code.

I think the issue is related to the language rules of CWTools (onEnterRules / indentationRules), because when you change the auto-indent settings (just change it, it doesn't really matter to what), the problem (at least temporarily) disappears. I'm not sure if these rules are determined on the CWTools back-end or in the hoi4config portion.

Here's a demonstration

Why does the YAML Parser restrict characters of desc?

I was working on my mod project, which uses Japanese as the main language
I used CWTools through the VSCode extension

But I found some errors like this issue
cwtools/cwtools-vscode#35

I've read the parser code, I found this lines

let inline isLocValueChar (c: char) =
isAsciiLetter c || (c >= '\u0020' && c <= '\u007E') || (c >= '\u00A0' && c <= '\u024F') || (c >= '\u0401' && c <= '\u045F') || (c >= '\u0490' && c <= '\u0491') || (c >= '\u2013' && c <= '\u2044')
|| (c >= '\u4E00' && c <= '\u9FFF') || (c >= '\uFE30' && c <= '\uFE4F') || (c >= '\u3000' && c <= '\u303F') || (c >= '\uFF00' && c <= '\uFFEF')

let desc = many1Satisfy isLocValueChar .>> spaces <?> "desc"

The function isLocValueChar returns true when c is an ascii letter or a Chinese character(\u4E00 - \u9FA0, ex. 漢), but not when c is a Japanese character Hiragana(\u3040 - \u309F, ex. ひ) or Katakana(\u30A0 - \u30FF, ex. カ), or a Korean character(\uAC00 - \uD7A3, ex. 한).
I think this restriction should be removed, but is there some reasons for it?

Setting up CWT for Linux

Hello there :)

I've tried to setup CWT on Linux, using VSC but I'm having only one problem:

  1. autocompletion
  2. the extension only checks errors in the localisation files

mod path: /home/atimpone/.local/share/Paradox Interactive/Europa Universalis IV/mod/
for the installation of EUIV I've found 2 path:

  1. /home/atimpone/.local/share/Steam/steamapps/common/Europa Universalis IV
  2. /home/atimpone/.steam/steam/steamapps/common/Europa Universalis IV

I've tried, as Vanilla EU4 (extension settings) to put both above, not at the same time obvs, and it has generated the vanilla file every time correctly (is there a way to make it build once again?) but after that, I just get this:

[Info  - 11:11:36] repo path "https://github.com/tboby/cwtools-eu4-config"
[Info  - 11:11:36] Client thinks this is a vanilla directory
[Info  - 11:11:36] New init { processId = Some 4087
  rootUri =
           Some
             file:///home/atimpone/.local/share/Steam/steamapps/common/Europa Universalis IV
  initializationOptions =
                         Some
                           {
  "language": "eu4",
  "isVanillaFolder": true,
  "rulesCache": "/home/atimpone/.vscode/extensions/tboby.cwtools-vscode-0.8.41/.cwtools",
  "rules_version": "latest",
  "repoPath": "https://github.com/tboby/cwtools-eu4-config"
}
  capabilitiesMap =
                   map
                     [("textDocument.codeAction.dynamicRegistration", true);
                      ("textDocument.codeLens.dynamicRegistration", true);
                      ("textDocument.colorProvider.dynamicRegistration", true);
                      ("textDocument.completion.completionItem.commitCharactersSupport",
                       true);
                      ("textDocument.completion.completionItem.deprecatedSupport",
                       true);
                      ("textDocument.completion.completionItem.preselectSupport",
                       true);
                      ("textDocument.completion.completionItem.snippetSupport",
                       true); ("textDocument.completion.contextSupport", true);
                      ("textDocument.completion.dynamicRegistration", true); ...]
  trace = Some Off
  workspaceFolders =
                    [{ uri =
                            file:///home/atimpone/.local/share/Steam/steamapps/common/Europa Universalis IV
                       name = "Europa Universalis IV" };
                     { uri =
                            file:///home/atimpone/.local/share/Paradox Interactive/Europa Universalis IV/mod/missionsmaster
                       name = "missionsmaster" };
                     { uri =
                            file:///home/atimpone/.local/share/Paradox Interactive/Europa Universalis IV
                       name = "Europa Universalis IV" }] }
[Info  - 11:11:36] New configuration { settings =
            {
  "cwtools": {
    "trace": {
      "server": "off"
    },
    "localisation": {
      "languages": [
        "English"
      ],
      "generated_strings": ":0 \"REPLACE_ME\"",
      "replaceme": ""
    },
    "errors": {
      "vanilla": "false",
      "ignore": [],
      "ignorefiles": [
        "README.txt",
        "credits.txt",
        "credits_l_simp_chinese.txt",
        "reference.txt",
        "startup_info.txt"
      ]
    },
    "experimental": "false",
    "debug_mode": "false",
    "rules...}
[Info  - 11:11:36] No cache path
[Diag - 11:11:36] queue length: 0
[Info  - 11:11:36] /home/atimpone/.local/share/Steam/steamapps/common/Europa Universalis IV
[Info  - 11:11:36] Parse docs time: 1
[Info  - 11:11:36] Vanilla folder, so not loading cache
[Info  - 11:11:36] Parse cache time: 0
[Diag - 11:11:36] lint force: true, shallow: false
[Error - 11:11:36] cwtools git error, recovering, error: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'git2-7ce88e6' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgit2-7ce88e6: cannot open shared object file: No such file or directory
   at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
   at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
   at LibGit2Sharp.Core.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at LibGit2Sharp.Core.NativeMethods.git_repository_open_ext(git_repository*& repository, FilePath path, RepositoryOpenFlags flags, FilePath ceilingDirs)
   at LibGit2Sharp.Core.Proxy.git_repository_open_ext(String path, RepositoryOpenFlags flags, String ceilingDirs)
   at LibGit2Sharp.Repository.IsValid(String path)
   at Main.Git.initOrUpdateRules(String repoPath, String gameCacheDir, Boolean stable, Boolean first)
[Diag - 11:11:36] lint after delayed
[Diag - 11:11:36] queue length: 0
[Info  - 11:11:52] Workspace roots:
[Info  - 11:11:52] root /home/atimpone/.local/share/Steam/steamapps/common/Europa Universalis IV, exists: true
[Info  - 11:11:52] root /home/atimpone/.local/share/Paradox Interactive/Europa Universalis IV/mod/missionsmaster, exists: true
[Info  - 11:11:52] root /home/atimpone/.local/share/Paradox Interactive/Europa Universalis IV, exists: true
[Info  - 11:11:52] embedded folder <null>
[Info  - 11:11:52] normalised /home/atimpone/.local/share/Steam/steamapps/common/Europa Universalis IV
[Info  - 11:11:52] normalised /home/atimpone/.local/share/Paradox Interactive/Europa Universalis IV/mod/missionsmaster
[Info  - 11:11:52] normalised /home/atimpone/.local/share/Paradox Interactive/Europa Universalis IV
[Info  - 11:11:57] Parsing 21304 files

after that, is just an endless repetition of [Info - 11:21:00] Unexpected scope RebelFaction and

[Info  - 11:21:03] getInfo missions/ME_Byzantium_Missions.txt /home/atimpone/.local/share/Paradox Interactive/Europa Universalis IV/mod/missionsmaster/missions/ME_Byzantium_Missions.txt
[Info  - 11:21:04] symbolInfoAtPos missions/ME_Byzantium_Missions.txt /home/atimpone/.local/share/Paradox Interactive/Europa Universalis IV/mod/missionsmaster/missions/ME_Byzantium_Missions.txt
Looking for effect "none" in the 0 effects loaded
[Info  - 11:21:04] symbolInfoAtPos missions/ME_Byzantium_Missions.txt /home/atimpone/.local/share/Paradox Interactive/Europa Universalis IV/mod/missionsmaster/missions/ME_Byzantium_Missions.txt
Looking for effect "none" in the 0 effects loaded
[Diag - 11:21:05] lint after delayed
[Info  - 11:21:05] /home/atimpone/.local/share/Paradox Interactive/Europa Universalis IV/mod/missionsmaster/missions/ME_Byzantium_Missions.txt
[Info  - 11:21:05] Validating 1 files
[Info  - 11:21:05] Localisation check 1 files
[Info  - 11:21:05] Localisation check took 4ms
[Info  - 11:21:05] Update Time: 142
[Diag - 11:21:05] queue length: 0

Screenshot from 2020-06-25 11-24-04

What should I fix?
Additional info:

  1. Fedora 32
  2. Gnome on Xorg (the game won't launch on Wayland)

EU4 building scopes

In EU4, there is on_built and on_destroyed keys for buildings in the buildings folder, but CWTools doesnt recognise these and throws errors.

Expand the html docs generator

The html docs generated from the rules are a proof of concept, but would probably be very useful if expanded: https://cwtools.github.io/cwtools-hoi4-config/

Small tasks that come to mind:

  • Update it with new rules/values (e.g. the compiler warnings about incomplete match cases)
  • Handle the new ~/strictMin cardinality
  • Add information about subtypes and which rules change dependant on them

The rules are defined/parsed in CWTools\Rules\RulesParser.fs. There is some documentation of the rules format in https://github.com/tboby/cwtools/wiki/.cwt-config-file-guidance

scope stack doesn't allways display or doesn't display proper scope or doesn't handle scopes correctly in certain instances

Example for displaying incorrectly:
if a decision is a targeted_decision towards a state the FROM scope should be a state, but in the tooltip says FROM is a country scope. It does handle it as as state scope though.

image
image
image

Example for not handling:
in on_actions a on action like on_unit_leader_promote_from_ranks_veteran will allow any trigger or effect in it's effect block. Like it allows a trigger that requires a country scope and a trigger that requires a state scope at the same time on the same level.

image
image
image

I've been trying to work around by editing the hoi4 cwt rules but haven't had any luck with getting the on_actions to work

EU4 variable localisation

Cwtools is throwing errors atm for all uses of variables in localisation, using the syntax [SCOPE.varname.GetValue]. Examples are [This.targetvassal02.GetValue]. The key is GetValue, which is uses specifically for variables. The error is always
Localisation key "localisation_name_here" uses command "varname" which doesnt exist CW226

M&T for EU4 uses a key system, which means every variable has a corresponding localisation key linking it to a shortened var. This means alot of errors.

Parsing colors.txt breaks files in HoI4

When you parse colors.txt or cosmetic.txt in HoI4, you will find the files broken.

Before parsing

GER = {	#Germany
	color = rgb { 60 60 60 }
	color_ui = rgb { 60 60 60 }
}

After parsing

GER = {
	#Germany
	color = {
		60
		60
		60
	}
	color_ui = {
		60
		60
		60
	}
}

This change breaks coloring system in hoi4.
You will find weird color on Germany after restarting game.
I hope cwtools support rgb style notation.

Anyway, we can make mods far easily because of this extension! Thank you!

Support for square bracket parameters in scripted_effects and scripted_triggers

Hey, would it be possible to add support for square bracket parameters? The way they work is if paramater in bracket is passed, the rest of racket is executed. The dollar and bracket parameters can overlap. I could try make change but never used F#

#Province effect
upgrade_building = {
	[[trade]
		if = {
			limit = { has_building = trade_depot }
			add_building = stock_exchange
		}
		else_if = {
			limit = { has_building = marketplace }
			add_building = trade_depot
		}
	]
	[[government]
		if = {
			limit = { has_building = courthouse }
			add_building = town_hall
		}
	]
}

upgrade_building = { trade = yes }
define_advisor_of_random_type = {
  define_advisor = {
	  [[name] name = $name$ ]
	  type = treasurer
	  skill = $skill$
	  [[culture] culture = $culture$ ]
	  [[religion] religion = $religion$ ]
	  [[discount] discount = $discount$ ]
	  [[cost_multiplier] cost_multiplier = $cost_multiplier$ ]
  }
}

define_advisor_of_random_type = { skill = 1 culture = some_culture }

Use this with C++

Hello,

Can't find any contact info for you. So I'm posting this as an issue.

Could you please add (or let me know how) to use your library with a standard C++ program?
I have little experience with cross-language interface management, F#, and C# in general.......

I'm writing a calculator for HOI4 right now, and would prefer to load unit stats directly from game files.
Hence the need for a parser.

Add JSON serialisation/deserialisation of script files to the CLI

A script <-> JSON converter would make it easier for other applications to manipulate script files without writing yet another parser. This would be an extra command on the CLI project (although the actual serialization could be part of the main project).

On first investigation there are two possible forms:
Verbose

[
  {
    "key": "id"
    "value": [ ... ]
    "operator": "="
  },
  {
    "key": "desc"
    "value": "blah"
    "operator": "="
  },
  { 
    "value": "something"
  }
]

Compact

[
  {
    "id": [ ... ]
    "operator": "="
  },
  {
    "desc": "blah"
    "operator": "="
  },
  "something"
]

The verbose form is safer, and would let us add metadata to the output (e.g. localisation). It's also easier to parse back into script.

The compact form might be more convenient for quick read-only use.

Tasks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.