How are games made ‘moddable’ without revealing source code?

1.07K views

Do they just have a very abstract and capable API? some mods for some games can be pretty complex.

In: Technology

6 Answers

Anonymous 0 Comments

More or less. It depends on the game. Some just offer great hooks that allow people to write scripts to accomplish their goals. Other games have a very fixed file structure and will essentially grab mod folders and treat them as an extension of their data store, running everything contained therein: Does your mod have a folder named “government_types”?, well ,everything contained therein will be treated as a government type definition for this game.

You don’t need to reveal the source code to make something moddable, all you need is allow modders an entry point to extend the functionality and robust documentation so that people know what to do.

Anonymous 0 Comments

So one thing to remember is that there is source code and then there are game resources (graphics, sounds, parameters stored in text files, etc). Usually modding is done by modifying resources. To take an example – let’s say that you have a car racing sim. The game will have a folder structure where you can throw in car “skins” or models, it may provide the ability to enter the car’s parameters in a text file (how much power it has, how much tire grip, etc). Game’s source code will “know” where to look for those resources and how to use them, provided they have the right structure and format.

I don’t think APIs are used that much for typical modding. They may be used more for capturing game data. In the racing game example, it may allow you, for example, to capture more telemetry than the basic game.

Anonymous 0 Comments

Most games do not store their game data the same way they store their code. So it is possible to reveal the format of the game data and not the code. This makes it possible to change or add textures, 3D models or even complete levels. Some games might even have systems for the NPCs and scripted events in an easy format that can be changed. This may have started off as a way for the level designers to work independently from the coders but have the effect that third parties might also change the game content.

A lot of games is also written in a way that makes it relatively easy to reverse engineer the source code. Languages such as Java and C# have the disadvantage that the resulting compiled code is relatively easy to decompile. You may not have the variable names and the exact structure which makes it a bit hard to work with but it will allow you to make changes and test them out.

Anonymous 0 Comments

In addition to what has been mentioned, a lot of games use text-based scripting or data because it is quick and easy to read, modify and troubleshoot and modder can easily alter those. Generally games that are the most moddable are the ones who use those most extensively.

Anonymous 0 Comments

Having modded Factorio, Stellaris, and Space Engineers, I feel slightly qualified to attempt an answer.

For these three games, the actual game content is not part of the source code. Factorio, for instance, runs the base game as a mod, that you could disable. The game exe is the source code that grabs all files pertaining to the game, and loads them, and has very little of the game content within, only having the game engine to make the content all work together.

Moddability is also very different from game to game. For instance, Space Engineers allows mods to run actual code, C# I think, while blocks and items are defined using something else.

Factorio mods use Lua for everything, which means what the mod can do is only limited by what the devs allow.

Stellaris uses base text definitions and a simple base text scripting unique to Stellaris in particular. Even the other Paradox games don’t have all the same functions, or even have functions not available to Stellaris scripting.

There are advantages, and disadvantages, to each of these approaches. For instance, since Stellaris is so simple, it’s relatively easy for anyone to do something in it. However, documentation is specific to Stellaris only.

Factorio using Lua means you can use all that documentation, but Lua is a bit more complex, so some might be turned away.

Space Engineers is incredibly event moddable due to the choice of code directly run by the game. But is still limited by the API of what the devs allow modders access to.

Anonymous 0 Comments

This video is great: https://www.youtube.com/watch?v=A9U5wK_boYM

The guy goes into detail about how he reverse engineers the byte code into something that resembles the original source, all so he can fix a bug in the game that was bothering him.