Class mct_mod
The mct_mod object.
This holds all of the details for one mod - name, author, available options, UI appearances, etc.
Methods
mct_mod:new (key) | For internal use, called by the MCT Manager. |
mct_mod:save_mct_settings () | INTERNAL USE ONLY. |
mct_mod:get_section_by_key (section_key) | Getter for any mct_sections linked to this mct_mod. |
mct_mod:add_new_section (section_key, localised_name, is_localised) | Add a new section to the mod's settings view, to separate them into several categories. |
mct_mod:get_options_by_section (section_key) | Returns a k/v table of {option_key=option_obj} for options that are linked to this section. |
mct_mod:get_sections () | Returns a table of all "sections" within the mct_mod. |
mct_mod:set_log_file_path (path) | Set the log file path, relative to the Warhammer2.exe folder. |
mct_mod:get_log_file_path () | Getter for the log file path. |
mct_mod:set_section_visibility (section_key, visible) | Set the rows of a section visible or invisible. |
mct_mod:get_last_section () | Internal use only, no real need for use anywhere else. |
mct_mod:get_key () | Getter for the mctmod's key -- @treturn string key The key for this mctmod |
mct_mod:sort_sections () | Call the internal .sectionsortorderfunction, determined by mct_mod:set_section_sort_function -- @local |
mct_mod:sort_sections_by_key () | One of the default sort-section function. |
mct_mod:sort_sections_by_index () | One of the default sort-section functions. |
mct_mod:sort_sections_by_localised_text () | One of the default sort-option functions. |
mct_mod:set_section_sort_function (sort_func) | Set the section-sort-function for this mod's sections. |
mct_mod:set_option_sort_function_for_all_sections (sort_func) | Set the option-sort-function for every section Triggers mct_section:set_option_sort_function for every section. |
mct_mod:are_any_settings_not_default () | Check if any selected settings are not default! |
mct_mod:get_settings () | Returns the finalized_settings field of this mct_mod. |
mct_mod:set_title (title_text, is_localised) | Enable localisation for this mod's title. |
mct_mod:set_author (author_text) | Set the Author text for this mod. |
mct_mod:set_description (desc_text, is_localised) | Enable localisation for this mod's description. |
mct_mod:get_title () | Grabs the title text. |
mct_mod:get_author () | Grabs the author text. |
mct_mod:get_description () | Grabs the description text. |
mct_mod:get_localised_texts () | Returns all three localised texts - title, author, description. |
mct_mod:get_options () | Returns every mct_option attached to this mct_mod. |
mct_mod:get_option_keys_by_type (option_type) | Returns every mct_option of a type. |
mct_mod:get_option_by_key (option_key) | Returns a mct_option with the specific key on the mct_mod. |
mct_mod:add_new_option (option_key, option_type) | Creates a new mct_option with the specified key, of the desired type. |
mct_mod:delete_option (option_key) | This function removes an mct_option from this mct_mod. |
Methods
- mct_mod:new (key)
-
For internal use, called by the MCT Manager.
Parameters:
- key string The identifying key for this mod object.
See also:
- mct_mod:save_mct_settings ()
-
INTERNAL USE ONLY.
-- This constructs the string used in mctsettings.lua, for this mod.
-- Done as a method of mctmod so we can read mctmod/mctoption where necessary.
-- For instance, used to enact precision on slider floats.
-- @treturn string The mct_settings.lua string for this mod, ie.
["mod_key"] = {["option_key"] = "setting", ...}
- mct_mod:get_section_by_key (section_key)
-
Getter for any mct_sections linked to this mctmod.
-- @tparam string sectionkey The identifier for the section searched for.
-- @treturn mct_section
Parameters:
- section_key
- mct_mod:add_new_section (section_key, localised_name, is_localised)
-
Add a new section to the mod's settings view, to separate them into several categories.
-- When this function is called, it assumes all following options being defined are being assigned to this section, unless further specified with
-- mctoption.
-- @tparam string sectionkey The unique identifier for this section.
-- @tparam ?string localised_name The localised text for this section. You can provide a direct string - "My Section Name" - or a loc key - "
loc_key_example_my_section_name
". If a loc key is provided, it will check first at runtime to see if that localised text exists. If no localised_name is provided, it will default to "No Text Assigned". Can leave this and the other blank, and use mct_section:set_localised_text instead. -- @tparam ?boolean islocalised If a loc key is provided in localisedname, set this to true, please. -- @treturn mctsection Returns the mctsection object created from this call.Parameters:
- section_key
- localised_name
- is_localised
- mct_mod:get_options_by_section (section_key)
-
Returns a k/v table of
{option_key=option_obj}
for options that are linked to this section. -- Shouldn't need to be used externally. -- @tparam string sectionkey The unique identifier for this section. -- @treturn {[string]=mctoption}Parameters:
- section_key
- mct_mod:get_sections ()
- Returns a table of all "sections" within the mct_mod. -- These are returned as an array of tables, and each table has two indexes - ["key"] and ["txt"], for internal key and localised name, in that order.
- mct_mod:set_log_file_path (path)
-
Set the log file path, relative to the Warhammer2.exe folder.
-- Used for the logging tab. If nothing is set, the logging tab will be locked.
-- @tparam string path The path to the log file. Include the file extension!
Parameters:
- path
- mct_mod:get_log_file_path ()
- Getter for the log file path. -- @treturn string
- mct_mod:set_section_visibility (section_key, visible)
-
Set the rows of a section visible or invisible.
-- @tparam string section_key The unique identifier for the desired section.
-- @tparam boolean visible Set the rows visible (true) or invisible (false)
Parameters:
- section_key
- visible
- mct_mod:get_last_section ()
- Internal use only, no real need for use anywhere else. -- Specifically used when creating new options, to find the last-made section. -- @local
- mct_mod:get_key ()
- Getter for the mctmod's key -- @treturn string key The key for this mctmod
- mct_mod:sort_sections ()
- Call the internal .sectionsortorderfunction, determined by mct_mod:set_section_sort_function -- @local
- mct_mod:sort_sections_by_key ()
- One of the default sort-section function. -- Sort the sections by their section key - from "!mysection" to "zzzmy_section"
- mct_mod:sort_sections_by_index ()
-
One of the default sort-section functions.
-- Sort the sections by the order in which they were added in the
mct/settings/?.lua
file. - mct_mod:sort_sections_by_localised_text ()
- One of the default sort-option functions. Sort the section by their localised text - from "Awesome Options" to "Zoidberg Goes Woop Woop Woop"
- mct_mod:set_section_sort_function (sort_func)
-
Set the section-sort-function for this mod's sections.
You can pass "key_sort" for mct_mod:sort_sections_by_key.
You can pass "index_sort" for mct_mod:sort_sections_by_index.
You can pass "text_sort" for mct_mod:sort_sections_by_localised_text.
You can also pass a full function, see usage below.
Parameters:
- sort_func function, "key_sort", "index_sort" or "text_sort" The sort function provided. Either use one of the two strings above, or a custom function like the below example.
Usage:
mct_mod:set_sections_sort_function( function() local ordered_sections = {} local sections = mct_mod:get_sections() for section_key, section_obj in pairs(sections) do ordered_sections[#ordered_sections+1] = section_key end -- alphabetically sort the sections table.sort(ordered_sections) -- reverse the order table.sort(ordered_sections, function(a,b) return a > b end) end )
- mct_mod:set_option_sort_function_for_all_sections (sort_func)
-
Set the option-sort-function for every section
Triggers mct_section:set_option_sort_function for every section.
If you want to make 6 sections with "keysort", and a 7th with "indexsort", use this first after making all sections and then use mct_section:set_option_sort_function on the 7th afterwards.
Parameters:
- sort_func any See the wrapped function for what this argument needs to be.
- mct_mod:are_any_settings_not_default ()
- Check if any selected settings are not default!
- mct_mod:get_settings ()
-
Returns the
finalized_settings
field of this mct_mod. - mct_mod:set_title (title_text, is_localised)
-
Enable localisation for this mod's title. Accepts either finalized text, or a localisation key.
Parameters:
- title_text
string
The text supplied for the title. You can supply the text - ie., "My Mod", or a loc-key, ie. "uitextreplacementsmydope_mod". Please note you can also skip this method, and just make a loc key called:
mct_[mct_mod_key]_title
, and MCT will automatically read that. - is_localised boolean True if the title_text supplied is a loc key.
- title_text
string
The text supplied for the title. You can supply the text - ie., "My Mod", or a loc-key, ie. "uitextreplacementsmydope_mod". Please note you can also skip this method, and just make a loc key called:
- mct_mod:set_author (author_text)
-
Set the Author text for this mod.
Parameters:
- author_text
string
The text supplied for the author. Doesn't accept loc-keys. Please note you can skip this method, and just make a loc key called:
mct_[mct_mod_key]_author
, and MCT will automatically read that.
- author_text
string
The text supplied for the author. Doesn't accept loc-keys. Please note you can skip this method, and just make a loc key called:
- mct_mod:set_description (desc_text, is_localised)
-
Enable localisation for this mod's description. Accepts either finalized text, or a localisation key.
Parameters:
- desc_text
string
The text supplied for the description. You can supply the text - ie., "My Mod's Description", or a loc-key, ie. "uitextreplacementsmydopemoddescription". Please note you can also skip this method, and just make a loc key called:
mct_[mct_mod_key]_description
, and MCT will automatically read that. - is_localised boolean True if the desc_text supplied is a loc key.
- desc_text
string
The text supplied for the description. You can supply the text - ie., "My Mod's Description", or a loc-key, ie. "uitextreplacementsmydopemoddescription". Please note you can also skip this method, and just make a loc key called:
- mct_mod:get_title ()
-
Grabs the title text. First checks for a loc-key
mct_[mct_mod_key]_title
, then checks to see if anything was set using mct_mod:set_title. If not, "No title assigned" is returned.Returns:
-
string
titletext The returned string for this mctmod's title.
- mct_mod:get_author ()
-
Grabs the author text. First checks for a loc-key
mct_[mct_mod_key]_author
, then checks to see if anything was set using mct_mod:set_author. If not, "No author assigned" is returned.Returns:
-
string
authortext The returned string for this mctmod's author.
- mct_mod:get_description ()
-
Grabs the description text. First checks for a loc-key
mct_[mct_mod_key]_description
, then checks to see if anything was set using mct_mod:set_description. If not, "No description assigned" is returned.Returns:
-
string
descriptiontext The returned string for this mctmod's description.
- mct_mod:get_localised_texts ()
-
Returns all three localised texts - title, author, description.
Returns:
- string titletext The returned string for this mctmod's title.
- string authortext The returned string for this mctmod's author.
- string descriptiontext The returned string for this mctmod's description.
- mct_mod:get_options ()
- Returns every mct_option attached to this mct_mod.
- mct_mod:get_option_keys_by_type (option_type)
-
Returns every mct_option of a type.
Parameters:
- option_type string The option_type to limit the search by.
- mct_mod:get_option_by_key (option_key)
-
Returns a mct_option with the specific key on the mct_mod.
Parameters:
- option_key string The unique identifier for the desired mct_option.
Returns:
- mct_mod:add_new_option (option_key, option_type)
-
Creates a new mct_option with the specified key, of the desired type.
Use this! It calls an internal function, mct_option.new, but wraps it with error checking and the like.
Parameters:
- option_key string The unique identifier for the new mct_option.
- option_type string The type for the new mct_option.
- mct_mod:delete_option (option_key)
-
This function removes an mct_option from this mctmod. Be very sure you want to call this - it can have potential unwanted repercussions.
This means the mctoption is gone entirely - it won't be in the UI, it won't be tracked in settings (but it will be cached), it won't be obtainable using
get_option_by_key()
.Parameters:
- option_key string The option that's being disgustingly destroyed, how dare you?