ModCore
Updated for version 3.38.
Config/XML parameters
Parameter | Type | Description |
---|---|---|
name | String | Optional name of the mod to be used for logging. Defaults to the folder name of the mod |
author | String | Optional name of the author of the mod. Will show up in the mods list |
global_key | String | Optional global key for the mod class. If it doesn't exist already it will create the global |
priority | Number | A number that determines the priority of the mod. Similarly to BLT's priority, the higher it is the earlier the mod will load |
min_lib_ver | Float | Minimum version of BeardLib that the mod can load in. If your mod uses a new feature that can cause issues/crashes in older versions, use this! |
core_class | String | Path to the core class. If no class will be returned it will use ModCore as the class. If you have set a global key you can use that global key to add functions to your ModCore class. See in functions for the currently available functions |
load_first | Table | A table of strings of which modules to load first |
no_disabled_updates | Boolean | Determines if the mod should not be updatable when disabled by an error |
notify_about_version | Boolean | Determines if BeardLib should notify the user if they are running an older version of BeardLib that does not work with the mod. Defaults to true |
post_init | String | Path/name of the function that should be called after ModCore's |
ignored_modules | Table | A table of modules that should be ignored. Highly specific use cases where you want to postpone the initialization of some modules |
post_hook | String | Optional value that lets you initialize your BeardLib mod through a post hook script |
pre_hook | String | Like |
All of these values are available through self._config after the mod gets initialized. Feel free to include your own values in the XML.
Functions
Function | Description |
---|---|
init(String config_path, Boolean load_modules) | The init function of the class. If the mod isn't disabled it will load the config file |
PostInit() | Post init of the mod. In this stage many modules get fully loaded. |
InitModules() | Initializes all the modules that have been defined by the mod. Calling this is only necessary when |
LoadConfigFile(String path) | Loads the config file and sets a few variables based on it. |
AddModule(Table module_tbl) | Initializes a module and adds it to self._modules. This was separated from |
Log(String str, ...) | A log function. The parameters act like string.format |
Err(String str, ...) | Logs an error message to the console ([ERROR] + message). The parameters are like in string.format. The errors get logged and shown in errors dialog if developer mode is active |
LogErr(...) | Same as |
Warn(String str, ...) | Logs a warning message to the console ([WARN] + message). The parameters are like in string.format |
RegisterHook(String source_file, String file, Boolean pre) | Registers a script hook. |
ForceDisable() | Disables the mod. Make sure to call this before the mod gets fully initialized. This only disables the mod for the current lua state |
Get functions
Function | Return type | Description |
---|---|---|
GetRealFilePath(String path, Table lookup_tbl) | String | Returns a version of the passed string |
StringToValue(String str) | Any | Converts |
StringToCallback(String str) | Function | Converts |
GetPath() | String | Returns self.ModPath, the path of your mod (where main.xml resides) |
Enabled() | Boolean | Returns a boolean determining if the mod is enabled |
Disabled() | Boolean | Returns a boolean determining if the mod is disabled |
GetName() | String | Returns self.Name, the name of the mod |
Config() | Table | Returns self._config, the config (ie, xml) of the mod |
Priority() | Number | Returns self.Priority, the priority of the mod |
IsBLTMod() | Boolean | Returns true if the mod is a BLT mod (that uses BeardLib) |
Modules() | Table | Returns a table with all loaded modules |
GetModule(String type_name) | Any module | Return the first module with the type name |
GetModuleIndex(ModuleBase m) | Number | Return the index of module |
GetModules(String type_name) | Table | Returns a table of every module with type name |
core_class
functions
core_class
functionsFunctions to be used by core_class
functions. Just create the functions in the class inside core_class.
Function | Description |
---|---|
Init() | The function where you should write the initiailzation code for your mod. This is called after the modules get post initialized |
PreInit() | A function called earlier than |
PreInitModules() | The earliest point. Before modules are even initialized. Use this function to check for errors before the mod fully loads using |
Additional tips for core_class
If you need an update function you can add one using BeardLib:AddUpdater(String id, Function clbk, Boolean paused) and remove it using RemoveUpdater(String id).
Automatic icon You can have BeardLib automatically load the mod icon and set it for you. Just create an icon.png in the root of your mod.
Template
Download template here: https://github.com/Luffyyy/BeardLib-Templates/tree/master/BLT-Template
Last updated