Mod Settings Framework (Feature Selector)

If you liked this item, please rate it up on Steam Workshop page.

Author: bukowa

Last revision: 3 Apr at 13:49 UTC

File size: 379.69 KB

On Steam Workshop

Description:
Rome 2 ModSettings Framework

A simple framework for Total War: Rome 2 modders that allows for easy generation of frontend UI checkbox options and persistent user selections without touching UI files, simply by defining settings in a Lua file.

Instructions for Modders

  • Include ModSettings in your mod. There are two ways to do this:
    – a) Load the ModSettings mod alongside your mod; it will be available as a dependency.
    – b) RECOMMENDED: Copy the lua_scripts, modsettings, and ui folders, along with the modsettings.lua file, directly into your mod’s root directory.
  • Define your mod settings in the modsettings.lua file:
    return { ["a_first_setting"] = { text = "Enable Debug Logging", turned_on = false }, ["b_second_setting"] = { text = "Use Experimental Features", turned_on = true }, ["c_third_setting"] = { text = "Hardcore AI Mode", turned_on = false } }

  • Start the game and navigate to Settings -> Mods in the main menu:
  • In your campaign scripts, load the ModSettings framework and read the values:
    require ‘modsettings.init’ local is_hardcore = modsettings.core.get("b_hardcore_ai") if is_hardcore then — apply hardcore AI buffs require ‘my_hardcore_feature.lua’ end

Debugging

The framework is natively configured to hook into consul_logging if that module is loaded. This means the Consul Scriptum mod should be loaded if you wish to see log messages; however, it is not required for any other functionality.

Credits
  • The DEI Modding Workshop Discord channel and its community.

This mod would not have been possible without:

I also created this plugin for editing UI files:

License

You are free to use this framework in your mod without restrictions. We only ask that you include a link to this mod’s Steam page in your description so other modders can find and utilize it.

The code is licensed under the MIT License; see the LICENSE file for details.

Source

The source code for this framework is available on GitHub: https://github.com/bukowa/r2-modsettings