Supreme Commander Wiki


This page will describe how to make and package a mod, and how to add code into the game.
For description about the game modules go to Modules

Folder structure[]

The folders and scd's (they are zips) are mounted by the following script;
path = {}
local function mount_dir(dir, mountpoint)
    table.insert(path, { dir = dir, mountpoint = mountpoint } )

local function mount_contents(dir, mountpoint)
    LOG('checking ' .. dir)
    for _,entry in io.dir(dir .. '\\*') do
        if entry != '.' and entry != '..' then
            local mp = string.lower(entry)
            mp = string.gsub(mp, '[.]scd$', '')
            mp = string.gsub(mp, '[.]zip$', '')
            mount_dir(dir .. '\\' .. entry, mountpoint .. '/' .. mp)

mount_contents(SHGetFolderPath('PERSONAL') .. 'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\mods', '/mods')
mount_contents(SHGetFolderPath('PERSONAL') .. 'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\maps', '/maps')
mount_dir(InitFileDir .. '\\..\\gamedata\\*.scd', '/')
mount_dir(InitFileDir .. '\\..', '/')
The mods have to be inside the '/mods' folder either in an scd, in the root folder, or in the My Games folders.


mod_info.lua is the first file you'll need. You can define the name, version and other attributes of your mod there.
You have to put it in your mod's root folder aka.: '/mods/YourMod/mod_info.lua'
name = "ModName"
uid = "Use a guid generator to generate an uid, you can find one in the gpgnet folder"
version = 1
copyright = "GPL v3"
description = "Put your mod description there"
author = "You"
url = "mod url here"
icon = "icon path - /mods/YourMod/"
selectable = true -- can select in the mod manager?
enabled = true -- enabled by default
exclusive = false -- if true, this mod disables all other mods when enabled
ui_only = false -- if true, the mod is only initialized in the UI
requires = { } -- list of uids this mod requires
requiresNames = { } -- list of mod names this mod requires
conflicts = { } -- uids of the mod it doesn't work with
before = { } -- comes before these mods
after = { } -- comes after these mods


<the path '/mods/YourMod/' will be referred as '/' from now on>
To change / load new scripts in supcom, you'll have to hook existing scripts.
You have to put all these files in the '/hook/' folder.
Hooking concatenates your new file with the existing one, meaning you'll be able to access all the local variables. This also means that errors will output based on the line for the concatenated file. (e.g. If the original file is 250 lines long and there is a syntax error in your mod file at line 20, the log will show the error at line 270.)

Non-destructive hooking[]

You can put your code into a local scope, so other mods hooking the same file won't be able to access your variables, useful if two mods use the same variable name.
# some file
    <...your code here...>
To hook methods, you have to store the old method before defining the new one, and then call it in the new method.
Unfortunately, the local variables from the old methods are not accessible.
local oldMethod = Method
function Method(arg1, arg2)
    oldMethod(arg1, arg2)


Shadowing refers to overwriting the original file. This currently does not work with the mod manager, however you can use .scd packed archives, the files should keep the same path inside the scd as in the original.