@RavenCurow Hello, copied from a previous reply I posted on Discord:
lobbyoptions.lua
I'm using it because it is the earliest point where a normal mod code can run in the lobby. while loading, its ImportModAIOptions() imports lua/AI/LobbyOptions/lobbyoptions.lua from every installed mod, to read the mod's AI settings, importing a file runs all of its code, so besides giving back an empty AIOpts, ours adds Sentinels (my faction) to the lobby.
from FAF's faction list
factions.lua
i copy the UEF entry, rename it to Sentinels, and give it our icons and our commander id, then it is added to the end of the list, so lobby and my code shares the same list that way the lobby sees Sentinels(my faction) as faction 5 or (6 if Nomads enabled)
then i fill the extras needed: hover desc, list of AI names (without one the lobby errors), and purple skin
I keep random as the default, FAF works out which number means random with "last faction + 1" before we add ours, so i apply small fix
button and lobby background images are loaded from game folders that mods can't add files to. I catch those two image loads and swap in the files from the mod
extra fix for lobby.lua private list of faction names, it uses that list the background, skin and chat color. In this case my Sentinels fac is 5, which that list calls
"random faction"
, this list is private to the file, but one lobby function uses it so I wait for that function to be defined, then use Lua's debug tools to reach the list and rewrite it with real names (Sentinels name now included)
mod turned to ON when anyone presses launch.
after launch, so FAF loads its normal hooks like any mod's. hook/lua/factions.lua adds Sentinels to the game's faction list again.
and Voalah!
Testing Video
However, I'll be contributing to FAF to add an official way to easily add custom factions, since this method is very “hacky.”






