API:ModuleSetEnabled
From RoR Wiki
UI Lua API · Module functions
Version: WAR 1.4.8
Enables or disables a UI module (addon) by name.
ModuleSetEnabled(moduleName, enabled)
Arguments
- moduleName
string– The module's name, as in thenamefield of ModulesGetData. The comparison is case-sensitive.- enabled
boolean–trueto enable the module,falseto disable it.
Returns
Nothing.
Details
- Only the module's enabled flag is changed. A module that is already running is not shut down, and a newly enabled module is not initialized. The change takes effect the next time modules are initialized, which is why the stock UI reloads the interface right after calling it.
- The flag is reported as
isEnabledby ModulesGetData. enabledmust be a real boolean. Passingnilor a number raises an Invalid Parameters error.
Errors
These are written to the UI log; the call returns normally.
Error in function call 'ModuleSetEnabled': %s is not a valid UiMod name.
Example
From ea_uimodwindow/source/uimodwindow.lua:
function UiModWindow.SaveAndReloadMods()
WindowSetShowing( "UiModWindow", false )
for index, modData in ipairs( UiModWindow.modsListData ) do
ModuleSetEnabled( modData.name, modData.isEnabled )
end
BroadcastEvent( SystemData.Events.RELOAD_INTERFACE )
end
