Nathan Wailes - Blog - GitHub - LinkedIn - Patreon - Reddit - Stack Overflow - Twitter - YouTube
Making a moddable (extensible) game or game engine
An example of hard-coded (not easily-moddable) and "data-driven" (easily-moddable) programs:
# Not easily modddable: def program(): print("Hello world!") # Easily moddable: def program(): message_to_print = load_message_to_print() print(message_to_print) def load_message_to_print(): with open("config.json", "r") as infile: data = json.load(infile) return data['message_to_print']
Wikipedia
StackExchange
- I want to make a moddable game. How does this affect my programming language choice?
- There's good info here.
Minecraft for example is not a very moddable game at all, however there are pretty good decompilers available for Java and a very large community for Minecraft, so a lot of tools were made to make Minecraft moddable (various modloaders, Bukkit). With those tools it is possible to mod Minecraft (however they are, probably, technically illegal in some countries).
Best advice I can give you, is to use the tools you want modders to use; If you define a NPC from a file it can be modded, if you special case it in code it probably can't be.
OFP / Arma
- http://www.eurogamer.net/articles/2014-04-29-bohemias-war-the-story-of-the-company-behind-arma-and-dayz
- http://diaboliquemagazine.com/dayz-the-history-and-the-future/
Minecraft
2011 - Searge's MCP Mod System
How does it work?
I will add more information about the inner working of this on the wiki page later. For the moment you can either assume it magic or, if you know how Java works, think about derived classes and how function overloading and virtual calls are handled by the JVM.Basically it's a combination of a custom class loader and some custom classes "hooked" into the game.
- 2015.07 - Minecraft forum - The History of Modded Minecraft
[NW: Minecraft was released on May 17, 2009] By the end of 2009 (end of PreClassic) there were other sophisticated map editing tools, custom level generators, heightmaps to maps, the first map rendering tool, etc. but I digress. Certain players had started to try customizing server behaviour so as to allow for a shooting mechanism involving flowers[11]. World of Minecraft, a custom server with custom clients, was very popular. The first mod list is formed, although it is mostly texture packs and external map tools[12]. People start documenting client and server packets on the Minecraft Wiki[13], with much help from JTE's already finished work.
- 2016.06.03 - PacktPub - A Brief History of Minecraft Modding
This began to change, though, beginning with the creation of the Minecraft Coder Pack, which was later renamed the Mod Coder Pack, commonly known as MCP. (One of the primary creators of MCP, Michael “Searge” Stoyke, now actually works for Mojang.) MCP saw its first release for Alpha 1.1.2_01 sometime in mid 2010. Despite being easily decompiled, Minecraft code was also obfuscated. Obfuscation is when you take all the meaningful names and words in the code and replace it with non-human readable nonsense. The computer can still make sense of it just fine, but humans have a hard time. MCP resolved this limitation by applying meaningful names to the code, making modding significantly easier than ever before.
(...)
Seeing that their mods couldn’t be used together, the creators of several major mods launched a new project. They would call it Minecraft Forge. Started by Eloraam of Redpower and SpaceToad of Buildcraft, it would see rapid adoption by many of the major mods of the time. Forge built on top of ModLoader, greatly expanding the number of base hooks and allowing many more mods to work together than was previously possible. This ushered in the true “Golden Age” of modding, which would continue from Beta and into Release.- So basically, one way to have your game moddable is to have people be able to modify the source code. So it's sort-of open-source in that people can hook into things, but it's not open-source in the sense that people can do whatever they want with your code (like fork it or straight-up copy it).
- This is a really good article.