Introduction to modding

From Europa Universalis 2 Wiki
Jump to navigation Jump to search

Modding of the EU2 files is a way to enhance the playability and fun of the game.

The changes could be just some new events that you think are missing or a whole scenario with another time span. It could be corrections to make it behave more close to historical facts or it could be creating completely fantasy countrys.

Some basic advices follows here.

Backup files before modding

It's highly recommended that you take backup of the files before starting modding them.
This is regardless of whether the files - before the modding - is in the original installed status or if they already have been modified by earlier modding.

The best and simpliest way is to take a copy of the whole EU2 directory and place it on another physical (if possible) disk. If the target of your modding is a specific directory belonging to a mod that uses the "moddir" function (and therefore have its files in an own directory), then its enough to take a copy of that directory.

During the time you is modding it's recommended that you regularely take backup copys of the files you are changing. That way you is avoiding a high risk for heart attacks and serious disturbance in higher cerebral centra. :)

You can't take backup too often.

Organization of the files

If you are doing a real mod it's highly recommended that you use the "moddir" function and have a new directory for this (which should be a subdirectory to the EU2 directory).

If you is just doing some changes for your own pleasure you could have an own directory for this (without "moddir"). You include the files in this directory in the topmost scenariofile belonging to the scenario you is modding (in the "Scenarios" folder). (Although this is dependant on which type of files you are modding.)

Try to follow the organization of the files in the original EU2. Or follow the organization of the mod you are changing.

The format of the code used

The most commonly used code format in the EU2 files is as showed in this symbolic example:

# A comment.
objectname = {
       attribute1 = attributevalue1  # Another comment.
       attribute2 = "attributevalue2"
       subobjectname = { subattribute1 = subattributevalue1 subattribute2 = subattributevalue2 }
}

Note the use of "{ }" for grouping of the parameters. A very common misstake in modding is leaving out an ending "}". Or other incorrect usage of them.

Finding bugs

If you have a bug that you know was introduced by a specific set of changes, a simple but effective way to find the culprit is this:

  • Remove half of the changes.
  • If the bug is still there, iterate: again remove half of the remaining changes.
  • If the bug disappeared, reinstate half of the removed changes.
  • Continue until you have so little code left that you understand what had caused the bug.

Otherwise do the following in this order:

In any case do not post in e.g. these forum: "EU2 Bug reporting", "EU2 Tech support" or "EU2 - User made scenarios and mods".
That's because they are not meant for asking about bugs in mods.

For helpful information and tools look in the thread "Various useful tools and resources" in the "EU2 - Scenarios, Events and Modifications" forum.