How to make a mod that edits one of the .lua scripts?

pokiehl

Moderator
Moderator
Joined
Mar 5, 2017
Messages
4,166
I want to make a mod that will edit a lua script in the game's files that limits how many players can join a multiplayer game:

- local MAX_EVER_PLAYERS : number = 12;
-Fetch g_currentMaxPlayers because it might be stale due to loading a save.
g_currentMaxPlayers = math.min(MapConfiguration.GetMaxMajorPlayers(), 12);

It's in base/assets/ui/frontend/multiplayer/stagingroom.lua - I want to change those two 12's to a higher number (say 30).

I have no clue how to make 'update' actions in lua, and I don't even know what I'd set for an action in the SDK...Any help?
 
There's no way to edit only parts of a lua file, but you can replace the file by including an identically named lua file in your mod. The game will use your version of the file instead of the default one while your mod is enabled.

1) copy and paste stagingroom.lua into your mod.
2) make whatever changes you want to that copy of the file.
3) include it in your modinfo in the ImportFiles section.
 
Be aware that taking ownership of a Lua will make your mod incompatible with other mods that use that same Lua unless you merge your changes to the Lua (assuming both of your code changes are not exclusive)
 
Thanks for the heads up Kantorr. So just to recap, import the LUA, make my edits, then the only 'action' in Modbuddy is to do InGame Action --> Import File, correct? Or Would it be FrontEnd? I'm trying to upload changes to the Map River/Lake generator as well. Would the StagingRoom LUA be FrontEnd and the river/lake be InGame?
 
StagingRoom would be frontend and everything else ingame I believe. All mapscripts/generator functions are ingame for sure.
 
Back
Top Bottom