Supreme Commander Wiki


735pages on
this wiki
Add New Page
Talk0 Share

Modding Edit

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 Edit

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.

Mods Edit

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

Hooking Edit

<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 Edit

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 Edit

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.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.