-
Notifications
You must be signed in to change notification settings - Fork 21
Custom Libraries
Vexatos edited this page Dec 30, 2021
·
7 revisions
Lönn supports writing custom libraries and putting them in the libraries
folder. Libraries can help with reducing code duplication by putting shared code into a single place. Any plugin will be able to access and use the functions defined in those libraries, even plugins from other mods (any mod using such a library will have to add the mods containing the library as a dependency, of course). This also enables the release of pure "helper" plugins that assist with the making of other Lönn plugins.
The structure of a library is identical to the structure of any other Lua library. You can access a library by using mods.requireFromPlugin()
:
local mods = require("mods")
local customStuff = mods.requireFromPlugin("libraries.custom_stuff")
To load a library from another mod, you need to specify the mod name:
local mods = require("mods")
local otherCustomStuff = mods.requireFromPlugin("libraries.other_custom_stuff", "OtherHelper")