Foundation

Foundation

Foundation is a grid-less, sprawling medieval city building simulation with a heavy focus on organic development and monument creation.

Learn more and find the game on Steam, GOG.com, Facebook, Twitter, Youtube.

How to mod in Foundation

This guide will go step by step through the process of creating all the required files, folders, and settings to put a simple object into the game. This is a very basic guide to just get things started.

1 comment

Posted by on (updated ago)


Want to learn how to mod in Foundation? You've come to the right place.

Before we get started, I'm going to mention the programs I use to mod. There are of course other options for these 3 but this is what I personally use.

  • Visual Code Studio
  • Blender
  • Winrar

Step 1 - Creating the mod folder

Starting with the easiest part first, we'll create a new folder and name it whatever you'd like the mod to be called. We'll then create a couple of empty files and folders for now.

  • mod.lua
  • mod.json
  • models folder
  • localization folder

We'll come back to these a little later so, for now, go ahead and put the whole folder in your foundation mods directory as shown below. In this example mine is named "Boulder".

directory


Step 2 - Exporting the model

This guide assumes you know a little about basic 3d modeling, I'm mainly going to explain the export settings.

Once you have your model the way you like it we'll then have to do a couple of things first to make sure the model will show up in-game.

First is to create a new empty axis and then make sure the model is a child of that empty axis as shown below in the red box. You can then name the empty axis something, this will be important later on when we go to code everything. In my example, I'm naming mine "Boulder".

I also included in the screenshot how the texture should be set up so the game can read it.

untitled


Second is when we go to export the .fbx file, a couple of settings should be changed. Make sure the x-axis is forward and apply transform is checked as shown below. After that go ahead and export it into the "models" folder we created earlier. Also in that same folder is where we need to put the textures that will be used for the mod. Don't worry about the "meta" file now, it will be created automatically later on when we go to load the mod in-game.

exportmodels


Step 3 - Mod.lua file

Now we're on to the slightly harder part. Once you understand the Lua language creating mods will be a piece of cake.

For all the coding parts I personally use Visual Studio Code but you can also use Notepad++ or the regular windows notepad if you prefer.

The 3 main parts to this code are

  • The Asset Id
  • The Building
  • The Building Part

The second line of code is where we register the asset id. Change the .fbx name to whatever you named it when you exported earlier. Remember earlier when I said the name of the empty axis will be important? This will go after /Prefab/.

Everything is case sensitive so make sure your file names match the code and vice versa. For simplicity just change all the "boulders" in my code to whichever name you want.

local mod = foundation.createMod();

mod:registerAssetId("models/boulder.fbx/Prefab/Boulder", "PREFAB_BOULDER")

mod:register({
	DataType = "BUILDING",
	Id = "BOULDER",
	Name = "BOULDER_NAME",
	Description = "BOULDER_DESC",
	BuildingType = "DECORATION",
	BuildingPartSetList = {
		{ 
			Name = "BOULDER_NAME",
			BuildingPartList = { "BOULDER" }
		}
	}
})

mod:register({
	DataType = "BUILDING_PART",
	Id = "BOULDER",
	Name = "BOULDER_NAME",
	Description = "BOULDER_DESC",
	Category = "DECORATION",
	ConstructorData = {
		DataType = "BUILDING_CONSTRUCTOR_DEFAULT",
		CoreObjectPrefab = "PREFAB_BOULDER"
	}
})

There is a lot more you can do in this step to change quite a bit about the mod but for this guide, we won't worry about that.


Step 4 - Mod.json file

This file is for the details about your mod like the name or description. This is where we also include any additional languages. For now, we'll only worry about English just to keep it simple.

{
        "Name": "Giant Boulder",
	"Author": "RaisinMuff1n",
	"Description": "A giant decorative boulder",
	"Version": "1.0.0",
	
	"AdditionalLanguageList": [
		{
			"Name": "French",
			"Code": "fr"

		},
                {
			"Name": "German",
			"Code": "de"
		}
	]
}

Step 5 - Localization file

Within this folder will be all of our language files. Start by making a new folder and name it "en" with no quotes. Within this new folder, we need a new file that we will call text.json.

localization

{
    "BUILDINGS": {
        "BOULDER_NAME":"Giant Boulder"
       
    },

    "BUILDING_DESCRIPTIONS": {
        "BOULDER_DESC":"A giant decorative boulder"
    }
}

Congratulations! You just created your very first mod for foundation, all we need to do now is boot up the game, start a new game, and pick your mod from the list. The new model should show up under the decorations tab.

modlist

in game


Step 6 - Packaging mod for upload

You now have your mod completed and you want to share it with the rest of the community?

The upload process is pretty straight forward, the only thing I'm going to cover here is the zip file.

After you load your mod for the first time, a new file named "generated_ids.lua" will be created. It is updated automatically upon loading your mod in-game. Only the mod creator can generate this file so this is an important file to include in the upload along with anything else inside your mods folder. You don't want to zip up the main folder, only the contents of it as shown below. I personally use Winrar for this step and there are of course other options to use as well.

zip


Thank you for reading through my tutorial, if you have any comments, questions, or concerns please message me on Discord: RaisinMuffin#1879 or message me on this site. I hope this guide helped and I look forward to seeing your new mods in-game.

Comments

Join the community or sign in with your gaming account to join the conversation:

LU
LUCASTUCIOUS @lucastucious

Excellent tutorial ! Thank you