Scripting Tutorial
EU4 scripting can be intimidating for newcomers, regardless of previous programming experience. This guide will attempt to explain some of the idiosyncrasies of EU4 scripting, and give a general overview of how its different components fit together.
The Scripting Model[edit | edit source]
To begin to understand EU4 scripting we should first break it down into its most basic components, and show how they relate to and interact with each other.
The Game State[edit | edit source]
The Game State is an abstract concept that isn't actually part of EU4 scripting, but it's still helpful as it allows us to understand how the other components interact with each other. The Game State is basically how it sounds; the entire state of the game at a given moment. It encompasses all the values and variables attached to every country, province, trade node, and more. The Game State will tell you the primary culture of a given country, or even if that country exists at all. It can tell you how much treasury a country has, what the base production of a province is, or how many units of cavalry are in that province.
Scopes[edit | edit source]
- Main article: Scopes
Scopes are the context within which you can interact with the Game State. They are how you select what you are interacting with in that portion of code, whether that is a single country, a province, a region, or more. Scopes also determine which effects and triggers (covered in the next section) you can use, as some are only valid when used in a province scope, others are only valid when used in a country scope, and others still can be used in either province or country scopes.
Effects[edit | edit source]
- Main article: Effects
Effects are used to immediately make instant changes to the Game State. They are the primary way that you do things to the game in EU4 scripting. With effects, you can add to a country's treasury, change its religion or primary culture, or have one country completely take control of another country's provinces.
Triggers[edit | edit source]
- Main article: Triggers
Triggers are ways of getting info from the Game State about the conditions of the current scope. They let you check if a country is a certain religion, if they have an ally, or if a province has a certain amount of base manpower. Triggers can be used to further refine a set of scopes down to exactly what you want, or they can be used within a single scope to determine whether certain effects should be applied or not, or whether decision is visible or not.
Modifiers[edit | edit source]
- Main article: Modifier list
Modifiers are similar to Effects in that they alter the Game State, but they differ because Modifiers apply continuous effects to the Game State, while an Effect makes a one-off change instead. Modifiers are how you increase a country's tax income by a percentage (or fixed) amount, how you increase the number of available merchants, or how you increase the siege defensiveness of a province. Modifiers are applied to a scope directly by an effect, or by being coded into some other mechanic (like the modifiers a country gets from its religion). They can last for a fixed duration, for the life of a ruler, or for the rest of the game (unless programmatically removed).
Documentation | Effects • Triggers • Modifiers • Scopes • Variables • Localisation • Customizable localization • Run files • List of event pictures |
Scripting | Scripted function • Advisors • Ages • Bookmarks • Buildings • Casus belli • Colonial regions • Countries • Culture • Decisions • Defines • Diplomatic actions • Disasters • Empire of China • Estates • Events • Factions • Government • Government Mechanics • Great projects • History • Holy Roman Empire • Idea groups • Institutions • Mercenaries • Missions • Modifiers • Nation designer • On Actions • Parliament • Peace treaties • Policies • Rebel types • Religion • Subject types • Technology • Trade companies • Trade goods • Units |
Map | Map • Map Modding Quick Reference • Nation designer • Random New World • Trade nodes |
Graphics | 3D Models • Interface • Graphical Assets • Fonts • Particles • Shaders • Unit models |
Audio | Music • Sound |
Other | Console commands • Checksum • JoroDox mod making tool • Mod structure • Troubleshooting • The Validator • Run files |
Guides | Adding a province • Map Modding Quick Reference • Save-game editing • Scripting Tutorial |