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.

2 comments

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 Studio Code
  • Blender
  • Winrar

Below is an (optional) complete downloadable version of this mod. Also included inside the zip is an original .blend file for reference.


RaisinMuffin's Modding Tutorial - Beginners


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 "Cubes".


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 axes and then make sure the model is a child of that empty axes as shown below in the red box. You can then name the empty axes something, this will be important later on when we go to code everything. In my example, I made 2 objects which I'm naming "Cube_Part" and "Cube_Large_Part".

I also included in the screenshot, as seen near the bottom, how the texture should be set up so the game can read it. Just simply plug a texture node into the base color of the principled BSDF shader node and select your texture.


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.

export


Step 3a - Mod.lua file - Single Building Asset

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 - An ID for your model
  • The Building - The main monument building
  • The Building Part - The separate assets within the building

The first line of code is needed to create the mod. You can change "Tutorial" to whatever you would like just make sure they are all the same.

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 "cube" in my code to whichever name you want.

The below example is only for making a single object. For a monument style collection skip the code below and go to part 3b.

Since this is only for a single building, the "AssetCoreBuildingPart" is just going to be the ID of the single "BUILDING_PART" you have registered.

local Tutorial = foundation.createMod();

Tutorial:registerAssetId("models/cube.fbx/Prefab/Cube_Part", "PREFAB_CUBE_PART")

Tutorial:registerAsset({
    DataType = "BUILDING",
    Id = "CUBE",
    Name = "CUBE_NAME",
    Description = "CUBE_DESC",
    BuildingType = "DECORATION",
    AssetCoreBuildingPart = "CUBE_PART"
})

Tutorial:registerAsset({
    DataType = "BUILDING_PART",
    Id = "CUBE_PART",
    Name = "CUBE_NAME",
    Description = "CUBE_DESC",
    ConstructorData = {
        DataType = "BUILDING_CONSTRUCTOR_DEFAULT",
        CoreObjectPrefab = "PREFAB_CUBE_PART"
    }
})

Step 3b - Mod.lua file - Monuments

If you would like this to be a monument style collection, some changes need to be made to the "BUILDING" asset.

In the below example, we have the same code from above but with 3 differences:

  1. Another registered asset ID
  2. An extra "BUILDING_PART"
  3. The "BuildingPartSetList" added to our "BUILDING"

Within the "BuildingPartSetList" you would then just put the different "BUILDING_PART" objects. This list can have many different objects and we can even have multiple lists within the "BuildingPartSetList" for better organization.

Shown below, "BUILDING_PART_MONUMENT_POLE" would be the default "AssetCoreBuildingPart" that is used in the base game if you don't want to make your own.

You only need one asset in the list to make it a monument, however don't use the same asset for your core part as one that also on the list or you'll have some strange issues.

local Tutorial = foundation.createMod();

Tutorial:registerAssetId("models/cube.fbx/Prefab/Cube_Part", "PREFAB_CUBE_PART")
Tutorial:registerAssetId("models/cube.fbx/Prefab/Cube_Large_Part", "PREFAB_CUBE_LARGE_PART")

Tutorial:registerAsset({
    DataType = "BUILDING",
    Id = "CUBE_MONUMENT",
    Name = "CUBE_MONUMENT_NAME",
    Description = "CUBE_MONUMENT_DESC",
    BuildingType = "DECORATION",
    AssetCoreBuildingPart = "BUILDING_PART_MONUMENT_POLE",
    BuildingPartSetList = {
	{
	    Name = "CUBE_LIST_NAME",
	    BuildingPartList = {
               "CUBE_PART",
               "CUBE_LARGE_PART"
            }
	}
    }
})

Tutorial:registerAsset({
    DataType = "BUILDING_PART",
    Id = "CUBE_PART",
    Name = "CUBE_NAME",
    Description = "CUBE_DESC",
    ConstructorData = {
        DataType = "BUILDING_CONSTRUCTOR_DEFAULT",
        CoreObjectPrefab = "PREFAB_CUBE_PART"
    }
})

Tutorial:registerAsset({
    DataType = "BUILDING_PART",
    Id = "CUBE_LARGE_PART",
    Name = "CUBE_LARGE_NAME",
    Description = "CUBE_LARGE_DESC",
    ConstructorData = {
        DataType = "BUILDING_CONSTRUCTOR_DEFAULT",
        CoreObjectPrefab = "PREFAB_CUBE_LARGE_PART"
    }
})

There is a lot more you can do in this step from something simple like adding resource costs, desirability, and splendor gains, or even something more complicated like workplaces. For this guide however, we're going to keep it relatively simple.


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": "Decorative Cubes",
	"Author": "RaisinMuff1n",
	"Description": "A collection of decorative cubes",
	"Version": "1.0.0",
	
-- This below section is only needed for additional languages so feel free to delete this part if you'd like.
	"AdditionalLanguageList": [
		{
			"Name": "French",
			"Code": "fr"

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

For convenience I've included other common language codes below in case you'd like to use a different language. Just make sure to name your localization folder that same way.

Language	        Code
Chinese	            	ZH
French	            	FR
German  	        DE
Italian 	        IT
Japanese	        JA
Korean	            	KO
Russian	            	RU
Spanish	            	ES
Swedish	            	SV
Tagalog 	        TL

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.

For any other languages just create a different folder and use the language codes I posted above.

{
    "MONUMENT": {
        "CUBE_MONUMENT_NAME":"Cube Monument",
        "CUBE_MONUMENT_DESC":"A collection of decorative cubes",
        "CUBE_LIST_NAME": "Cubes"
    },
    "BUILDINGS": {
        "CUBE_NAME":"Cube",
        "CUBE_LARGE_NAME":"Large Cube"
    },
    "BUILDING_DESCRIPTIONS": {
        "CUBE_DESC":"A decorative cube",
        "CUBE_LARGE_DESC":"A large decorative cube"
    }
}

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

Cubes Mod List

Cubes CoverCubes Monument


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.


Contact & Help

Thank you for reading through my tutorial, I hope it helped and I look forward to seeing your new mods in-game.

If you have any comments, questions, or concerns please message me:

mod.iodiscordinstagram


For more in-depth modding capabilities go check out the Foundation API.

2 comments

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

ML
MsLyly83 @mslyly83

Thank you! This is what I needed.

LU
LUCASTUCIOUS @lucastucious

Excellent tutorial ! Thank you