• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

swwu

Recruit
80 Badges
Sep 12, 2011
3
2
  • Sword of the Stars II
  • For the Motherland
  • Hearts of Iron III
  • Heir to the Throne
  • Magicka
  • Europa Universalis IV: Res Publica
  • Semper Fi
  • Sengoku
  • Sword of the Stars
  • Crusader Kings II
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines Deluxe Edition
  • Stellaris: Synthetic Dawn
  • Cities: Skylines - After Dark
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Mare Nostrum
  • Europa Universalis IV: Mandate of Heaven
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Wealth of Nations
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Cities in Motion 2
  • Crusader Kings II: Sword of Islam
  • Europa Universalis III
  • Europa Universalis III Complete
  • Divine Wind
  • Europa Universalis IV
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Conquest of Paradise
  • Hearts of Iron IV: Field Marshal
  • Hearts of Iron IV: Colonel
  • Hearts of Iron IV: Cadet
  • Europa Universalis IV: Rights of Man
  • Hearts of Iron IV Sign-up
  • Tyranny: Archon Edition
  • Stellaris: Galaxy Edition
  • Stellaris
  • Crusader Kings II: Conclave
  • Crusader Kings II: Horse Lords
  • Pillars of Eternity
  • Crusader Kings II: Way of Life
  • Crusader Kings III
  • 500k Club
  • Europa Universalis III Complete
From what I can tell there are a lot of events in the current event-based systems that depend a lot on big lists of things for which the same event has to be duplicated - e.g. the artifact grant/confiscation system, the ethnicity trait assignment system, and parts of the magicka system.

Have people thought about using a template language to generate these event files instead? You could write the event as a template, and then compile it into its "raw" format with a .sh or a .bat file or whatever.

Just as an exercise I rewrote the current artifact_events.txt file using Jinja2 as a templating library:
https://gist.github.com/swwu/cf2114ffce1babf4eab1
For a total of about 410 lines of code, down from almost 9000 for the "raw" text version. It also has a few other benefits (e.g. changing the way artefacts are inherited or granted will now just require one code change instead of ~60 identical ones).

You can run it by just dropping both files into the same directory and running the python script (you need Python though, and Jinja2 installed somewhere on your python path). No particular attachment to Jinja in particular, it was just the easiest thing for me to pull in and get running.

Edit: here's the original artifact_events for comparison, as per r671 in SVN - https://gist.github.com/swwu/97dd440eb085f65f1478
 
  • 1
Reactions:

Zusk

Captain
83 Badges
Apr 29, 2011
446
96
  • Europa Universalis IV
  • 500k Club
  • Crusader Kings III
  • Crusader Kings III: Royal Edition
  • Battle for Bosporus
  • Europa Universalis 4: Emperor
  • Stellaris: Nemesis
  • Divine Wind
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II
This is a neat idea that might save some time! I was considering adding some more artefacts but the complexity of the system really turned me off from touching it.

I will have to try this out!