Comments (2)
Hi!
You're right, the interface has changed since then so that snippet doesn't work.
I've updated it so it works again.
Basically, most of the properties return read-only copies as F# has immutable data by default. There are four ways you can actually modify the data structure:
SetTag
which will look for the key and replace it, or add it if it isn't thereAllChildren
's setter, which takes a C# List and replaces all current children with itAll
's setter, which takes an F# List and replaces all current children with it it- `AllArray', which returns a mutable array (but not resizable), or the setter which replaces all current children with it
For "Leaf", both the Key and Value have setters. For "Node", the Key has a setter too.
//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.SetTag(leaf.Key, Child.NewLeafC(leaf));
// or
// var newChildren = myEvent.AllChildren;
// newChildren.Add(Leaf.Create(KeyValueItem.NewKeyValueItem(Key.NewKey("is_triggered_only"), Value.NewBool(true), Operator.Equals), range.Zero));
// myEvent.AllChildren = newChildren;
Hope that helps a little!
from cwtools.
Thank you for the in-depth answer!
Speaking of serializing, I have another question. I'm trying to modify a Crusader Kings III file programmatically and iteratively, and since the file is quite big I'd like to pickle the parsed data between runs. Is there a way to do so?
var processed = CWTools.CSharp.Parsers.ProcessStatements("testevent.txt", "./testevent.txt", eventFile);
var serialized_processed = JsonSerializer.Serialize(processed); // <--- Fails here: System.NotSupportedException: 'F# discriminated union serialization is not supported. Consider authoring a custom converter for the type.'
var deserialized_processed = JsonSerializer.Deserialize<Node>(serialized_processed);
File.AppendAllText("./serialized_node.txt", serialized_processed);
from cwtools.
Related Issues (20)
- political_leader_cost_factor unexpected? HOT 1
- Referencing trouble
- CK2 keep getting CW113 (file not found) if using "\\" in path
- CK2DNA validation
- RAM usage HOT 3
- CK3 Traits no longer require index
- How do I add a folder for "CWTOOLS LOADED FILES"?
- Add new directories for CWT to recognize HOT 2
- Allow icon[file/path] to recurse into sub-directories
- Parsing issues in Vic3 HOT 1
- Issue With Arithmetic Parsing in Stellaris
- Support for square bracket parameters in scripted_effects and scripted_triggers
- [Bug] Resource competition caused by multithreading HOT 3
- Program doesn't initialize, seemingly randomly HOT 2
- [BUG] Memory Consumption
- scope stack doesn't allways display or doesn't display proper scope or doesn't handle scopes correctly in certain instances HOT 2
- targeted variables don't work with scopes
- filepath doesn't check for .tga in case .dds doesn't exist and doesn't allow // in thefilepath
- [Localisation] Add support of some specific characters to loc parsing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cwtools.