User Tools

Site Tools


start

Welcome to the Foundation Modding Wiki

Warning

Modding capabilities are very embryonic. Expect a lot of improvement and changes in the future.

This documentation is a draft with a few guidelines, it will evolve gradually with the development of modding features.

Where do I start?

  • Create a new folder in Documents\Polymorph Games\Foundation\mods.
  • In your mod folder, create the main LUA script of your mod: mod.lua

The mod.lua script

First, you have to register your new mod:

mod.lua
local myMod = foundation.createMod({
	Name = "My First Mod",
	Author = "Leo",
	Description = "Best Mod Ever"
});

Including other LUA files

mod.lua is the only script file from your mod that will be automatically loaded.

In order to include another LUA file, you can call the dofile function on your mod:

myMod:dofile("anotherscript.lua")

This will execute the script anotherscript.lua from your mod folder. This will also pass the mod variable myMod to the script. So you will be able to access myMod from anotherscript.lua this way:

anotherscript.lua
local myMod = ... -- retrieve arguments passed to the script
 
-- do stuff with myMod
-- ...

In addition, you can pass any number of variable to the called script:

myMod:dofile("anotherscript.lua", 42, "A Super String", { 1, 4, 12 })
anotherscript.lua
local myMod, anInteger, aString, anArray = ... -- retrieve arguments passed to the script

Enabling / Disabling a mod

You can enable / disable mods from the Mods menu.

Be aware that even when a mod is disabled, most of the mod assets are loaded anyway, but are not active.

If you want to fully ignore a mod, you can either remove it from your mods folder, or rename the mod.lua file into something else (mod_.lua for instance).

Logging / Debugging

You can log your own logs into foundation log file:

myMod:log("Hello World!")
myMod:logWarning("This is a warning!")
myMod:logError("This is an error!")

You can also open a blocking message box for debugging purpose:

myMod:msgBox("Hello there!")

What is this generated_ids.lua file?

Internally, Foundation uses random unique IDs (GUID) to identify most objects and resources. When a new asset is added to the mod, Foundation will create a new ID for it, and will store the association between the “modding name” and the ID of the asset.

The generated_ids.lua file is where the association is stored. When you distribute your mod, it's important to distribute this file too. It will ensure that all your assets have the same ID from one player's computer to another, hence allowing them to share a save-game for instance.

Sharing a mod

Modders are encouraged to use mod.io to share their mods. Mods shared this way can be found and downloaded from the in-game mod browser.

Here is the Foundation page: https://foundation.mod.io

You'll have to upload a zip of your mod. Make sure the zip contains directly the mod files (mod.lua needs to be at the root of the zip).

start.txt · Last modified: 2018/12/07 17:06 by polymorphgames