Modding in 0.2

Hi everyone, it's Calandiel again ^ . ^ 

A fair warning, technical blabbering ahead

Today, I'd like to talk about modding in SotE. As some of you may know, we really hope to create a thriving modding community so we made sure that as much of the game is moddable as possible. In fact, the base game itself is considered a mod and an adventurous modder could easily replace SotE with, say, a visual novel. We achieved this by exposing all UI and data code so that it can be modified or overwritten as necessary.

The game lets users write Lua scripts which are then loaded by the engine and executed. This makes modding both easy to learn (you can still get by modifying numbers in text files or by copy pasting stuff from other mods) and very flexible (you have full power of a true programming language). In the future (say, updates 0.3, 0.4) we'll also expose functionalities that will allow modders to load arbitrary DLLs. And since all our data is already exposed through native pointers skilled modders will never have to compromise performance for usability ^ . ^

Our Lua interpreter is Moonsharp, which relies heavily on C# reflection. While that does make it slower than comparable interpreters it also allows us to easily expose all public objects and their methods (including Unity engine objects) to the modder. We'd like to empower the community and give you guys all the tools you need to change SotE to your liking. As such we're not planning to sandbox any of the engine features that would create arbitrary obstacles for mods (Demian had enough experience modding EU4 to share some horror stories with me).

As of 0.2, the base game will include examples of UI widgets, races, natural resources, flora and fauna packs, animals and plants. Those examples will hopefully have enough comments to be self explanatory (and if they do turn out to be too opaque, we'll also release some modding tutorials after 0.2 is out).

To give you a taste of how it looks like, here's an example of our debug flora and fauna pack:

-- Prepare an empty flora and fauna pack
local r = data:NewFNF()
-- Give it a name = "debug"
-- Define its animals and plants
r.animals = { "wolf", "deer" }
r.plants = { "oak_tree", "apple_tree" }
-- Save it to the database
data.fnfs[] = r

If this is too simple, here is a short walkthrough for adding a new natural resource to the game.

First, we need to create the mod itself. In SotE you just need to create an empty folder inside the mods directory. Like this:

Once we have it, we need to create a file called data.lua. The game executes code inside data.lua files for each enabled mod when the game is launched (and before the main menu is loaded). This file is generally meant to define shared data for worlds. Race definitions, good types, buildings, character portraits, natural resources, animal species definitions and other similar static game data should be defined inside data.lua (or in another file that is loaded from data.lua using Lua's 'require' function).

We'll add iron to the game. To do it, we need to edit data.lua and add the following:

local r = data:NewResource() = "iron"
r.R = 121
r.G = 163
r.B = 232
r.order = 1
data.resources[] = r;

Save the file, load the game and generate a new world. Iron should show up on the resource map mode:

Here is a very small deposit next to a bigger copper deposit. The process is very similar for other types of entities (races, goods, buildings, etc). Of course, we simplified things a bit and there are many more variables that you could modify to specify how iron should be generated. You'll be able to inspect those in more detail once 0.2 is released.

That's it for today. See you next week ^ . ^

(and don't worry, iron will actually be in the base game)

Get Songs of the Eons, 0.1.5

Leave a comment

Log in with to leave a comment.