> For the complete documentation index, see [llms.txt](https://luffyyy.gitbook.io/beardlib/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://luffyyy.gitbook.io/beardlib/api/frameworks.md).

# Frameworks

Updated for version 4.0.

Frameworks in BeardLib are a major part in BeardLib's mod loading, this is what loads the mods and gives them a place to stay in.

There are 3 frameworks in BeardLib: FrameworkBase, AddFramework and MapFramework.

Each framework gets added to this table: BeardLib.Frameworks. Each framework key is the type\_name of the framework so: BeardLib.Frameworks.Base, BeardLib.Frameworks.Add, and BeardLib.Frameworks.Map. These are the classes you'd want to call to use functions such as `GetModByName`.

## FrameworkBase

The base framework, all other frameworks inherit this framework. By itself, the framework loads any main.xml it finds inside **BLT** mods.

Access with `BeardLib.Frameworks.Base`

### Variables

| Parameter                   | Type    | Description                                                                                                                                                      |
| --------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \_directory                 | String  | The directory of the mods that the framework should load. In this case it's set to "mods/"                                                                       |
| \_mod\_core                 | Class   | The class that the mod of this framework should initialize in. All frameworks use [ModCore](https://luffyyy.gitbook.io/beardlib/api/modcore)                     |
| main\_file\_name            | String  | The main file that the framework should load. All frameworks use "main.xml"                                                                                      |
| auto\_init\_module          | Boolean | Automatically initialize the modules in this framework?                                                                                                          |
| \_ignore\_folders           | Table   | A table of folders that the framework should ignore. The values inside are folder = true                                                                         |
| \_ignore\_detection\_errors | Boolean | Determines if the framework should not log about folders it could not find a main.xml in the directory of the framework. Defaults to true (Except map framework) |
| menu\_color                 | Color   | The default color of mods that are inside this framework (Shown in the BeardLib mods manager)                                                                    |

### Functions

| Function                                                          | Description                                                                                                                                                                                               |
| ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| init()                                                            | The init function. Registers the framework to BeardLib using BeardLib:RegisterFramework and sets up stuff. Creates a hook that runs every time require is called and in that hook CheckModQueue is called |
| CheckModQueue(Booolean post, String file)                         | Called a few times to check for mods that are waiting to load through a post or pre hook                                                                                                                  |
| Load()                                                            | Called after init finished the setup process                                                                                                                                                              |
| FindMods                                                          | Searches for mods to load. Loads each mod using `LoadMod`                                                                                                                                                 |
| SortMods                                                          | Sorts the mods based on priority                                                                                                                                                                          |
| InitMods                                                          | Calls PreInitModules on mods to start loading the modules. Mods with `post_hook` or `pre_hook` will load be added to self.\_waiting\_to\_load                                                             |
| RegisterHooks()                                                   | Called automatically by a BeardLib hook for each framework from some point in tweakdata. This calls `DoRegisterHook` for modules and some modules use this point to add hooks for tweakdata               |
| log(s, ...)                                                       | A log function. Parameters act like string.format                                                                                                                                                         |
| DevLog(s, ...)                                                    | Same as log but only logs when BeardLib has developer mode on (mods folder needs to have mod.txt file and you need to turn on the option in BeardLib options)                                             |
| LoadMod(String folder\_name, String directory, String main\_file) | Instantiates a mod.                                                                                                                                                                                       |
| AddMod(String dir, ModCore mod)                                   | Adds the mod to the mod lists                                                                                                                                                                             |
| RemoveMod(String dir)                                             | Removes the mod from the mod lists                                                                                                                                                                        |

#### Get

| Function                  | Return Type | Description                                                                               |
| ------------------------- | ----------- | ----------------------------------------------------------------------------------------- |
| GetModByDir(String dir)   | ModCore     | Returns a mod based on a directory. For example mods/Holo will return HoloUI if exists    |
| GetModByName(String name) | ModCore     | Returns a mod based on a name. For example Sora HUD Reborn will return the Sora's HUD mod |

## AddFramework

The framework for mod overrides mods and add.xml.

Access with `BeardLib.Frameworks.Add`

### Variables

| Parameter    | Type  | Description                                                                        |
| ------------ | ----- | ---------------------------------------------------------------------------------- |
| add\_configs | Table | The table that holds all add.xml configs. Each config is stored in a mod path key. |

Inherits BaseFramework and does the following things:

* Allows loading a file named "add.xml" which is a quick and dirty way of loading AddFiles by modifying the `FindMods` function to pickup these files.
* Sets `_directory` to assets/mod\_overrides

## MapFramework

The framework for custom maps basically your "Maps" folder.

Access with `BeardLib.Frameworks.Map`

Inherits BaseFramework and does the following things: Sets `_directory` to "Maps" Sets `_ignored_folders` to {"backups", "prefabs"} to ignore the default editor folders

## Modules of interest

* [ContactModule](https://luffyyy.gitbook.io/beardlib/modules/contactmodule)
* [LevelModule](https://luffyyy.gitbook.io/beardlib/modules/levelmodule)
* [NarrativeModule](https://luffyyy.gitbook.io/beardlib/modules/narrativemodule)
* [LocalizationModule](https://luffyyy.gitbook.io/beardlib/modules/localizationmodule)

### Functions

| Function           | Description                                                                                   |
| ------------------ | --------------------------------------------------------------------------------------------- |
| AddCustomContact() | A function called from a modified `RegisterHooks` to create a default contact for custom maps |

#### Get

| Function                      | Return Type | Description                                                                 |
| ----------------------------- | ----------- | --------------------------------------------------------------------------- |
| GetMapByJobId(String job\_id) | ModCore     | Searches for a mod that has a narrative/job with id `job_id` and returns it |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://luffyyy.gitbook.io/beardlib/api/frameworks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
