1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

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

Discussion in 'Mod Creation Help' started by pokiehl, Mar 31, 2017.

  1. pokiehl

    pokiehl Emperor

    Joined:
    Mar 5, 2017
    Messages:
    1,185
    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?
     
  2. HandyVac

    HandyVac Gentleman

    Joined:
    Apr 24, 2014
    Messages:
    270
    Gender:
    Male
    Location:
    The shire where the oxen cross the river. UK.
    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.
     
    CupOfTea likes this.
  3. pokiehl

    pokiehl Emperor

    Joined:
    Mar 5, 2017
    Messages:
    1,185
    Awesome! Thank you so much HandyVac.
     
  4. kantorr

    kantorr Chieftain

    Joined:
    Mar 1, 2017
    Messages:
    51
    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)
     
    CupOfTea likes this.
  5. pokiehl

    pokiehl Emperor

    Joined:
    Mar 5, 2017
    Messages:
    1,185
    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?
     
  6. kantorr

    kantorr Chieftain

    Joined:
    Mar 1, 2017
    Messages:
    51
    StagingRoom would be frontend and everything else ingame I believe. All mapscripts/generator functions are ingame for sure.
     

Share This Page