hypixel skyblock
Dev icon This is a module documentation subpage for Module:LoadLib.
It contains usage information, categories and other content that is not part of the original module page.

This module is used to ease the loading of other modules. It does this by utilizing the global variable table, which allows for more flexibility in variables. It will also automatically load several modules.


Loading the module

To load this module and make it available for use, Add this line of code to the start of your module:

local loadLib = require('Module:LoadLib')

Auto-loaded Modules

This module automatically loads a preset list of commonly used modules. These names will be accessible through the Global Table of your code environment (_G.name or name). To better identify names for code tracing, see #Autoloads for a list of names.

Syntax

loadLib(<_G>(table)<t>(table)<options>(any))

Use

This module provides a singe function to load other modules.

This function has options that emulate normal lua code. Note that when ever using this function, you must use the following code format or this function or it will fail.

_G = loadLib(_G, {
    -- Any modules to load go here
})

Note that in these examples, sometimes the named table index is not omitted, which prevents the entire module from being loaded. If the table index is omitted, the loader will load the module under the index name.

Variable setting

You can also add the field setVars to true to make the loader set each method in the module as a variable in the loaded module.

Example

_G = loadLib(_G, {
    moduleName={ 'Module:ModuleName', setVars=true },
    -- Any other modules to load go here
})

Once this code is added to the module, any methods described in Module:ModuleName will be available as variables in the loaded modules with the variable name being the respective method in Module:ModuleName.

Paths

This module also provides basic relative paths and substitution variables. Any relative paths are substituted to absolute paths. These basic relative paths are the following:

Autoloads

LoadLib automatically loads a preset list of commonly used modules. These modules may be found in Autoloads.

These may be disabled entirely using options.doAutoLoads or some modules may be filtered using the options.skip parameter.

List of Automatically Loaded Names
Name Value Equivalent
string
require('Module:String')
makeLink
require('Module:String').makeLink
externalUrl
require('Module:String').externalUrl
fullUrl
require('Module:String').fullUrl
wrapTag
require('Module:String').wrapTag
wrapHtml
require('Module:String').wrapHtml
wrapLink
require('Module:String').wrapLink
makeTitle
require('Module:String').makeTitle
table
require('Module:Table')
constructor
require('Module:Constructor')
arguments
require('Module:Arguments')
getArgs
require('Module:Arguments').getArgs
yesno
require('Module:Yesno')
color
require('Module:Color')
makeColor
require('Module:Color')._colorTemplates
libraryUtil
require('Module:LibraryUtil')
currency
require('Module:Currency')
coins
require('Module:Currency').coins
gems
require('Module:Currency').gems
bits
require('Module:Currency').bits
rarityTier
require('Module:RarityTier')
makeRarity
require('Module:RarityTier')._link
rarityColor
require('Module:RarityTier')._colorText
makeStat
require('Module:Statname')._getStatName
item
require('Module:Item')
itemDisplay
require('Module:Item')._itemDisplay
link
require('Module:Link')
list
require('Module:List')
multiRequire
require('Module:Multirequire')

Variables

You can also use variables (denoted by ${<name>}) in the paths. These variables are substituted with the contents they repersent. The list of built-in variables is as follows:

Custom variables can be created by adding a table in the subst or substVars field in the <options> parameter. The table index in the table for variables represents the variable name, and the table value its contents. A custom variable may be called with the following syntax: ${var:<name>}

Example

The example variable here is set to Foo and it's name is foo. The page name in the example is Module:Test

Code Example

The current page name in this example is Module:String. Note that the current path "Module:Test/${page}/${var:foo}" will get subsituted to "Module:Test/String/Foo".

loadLib(_G, {
    test="Module:Test/${page}/${var:foo}",
}, {
    substVars={ foo="Foo" },
})

Note the module will throw an error if a custom variable does not exist or there is no substitution table to draw from. All methods from Module:Test/String/Foo will now be availible under the test object in the module the function was used.

Options

The following consists of different options for the loader to load the module. Note that you can group each of these options together in one loadLib() call.

Option: Simple Module Loading

This option replicates a standard require() call. See the section below for the Replicated code.

_G = loadLib(_G, {
    moduleName='Module:ModuleName'
    -- Any other modules to load go here
})

Once this line of code is added to your module, the module and its methods are available under the table index name. In this case, all methods of Module:ModuleName are available under the variable moduleName.

Replicated code

local moduleName = require('Module:ModuleName')

Option: Using Field

This option only loads a field from a library to the global table.

1

This option replicates a require() call and getting a single field from the module and setting that field name as the variable to be used. See the section below for the emulated code.

_G = loadLib(_G, {
    { 'Module:ModuleName', field='foo' }
    -- Any other modules to load go here
})

Once this code is added, the method foo() from Module:ModuleName is available under the foo variable.

Replicated code

local foo = require('Module:ModuleName').foo

2

This option replicates a require() call and getting a single field from the module and setting that field name as a different variable from the method name. See the section below for the emulated code.

_G = loadLib(_G, {
    bar = { 'Module:ModuleName', field='foo' }
    -- Any other modules to load go here
})

Once this code is added, the method foo() from Module:ModuleName is available under the bar variable.

Replicated code

local bar = require('Module:ModuleName').foo

Option: Using Values

1

This option replicates a require() call and getting multiple fields from the module and setting that field name as the variable to be used. See the section below for the emulated code.

_G = loadLib(_G, {
    { 'Module:ModuleName', values={ 'foo', 'bar', 'baz' }
    -- Any other modules to load go here
})

Once this code is added, the methods foo(), bar(), and baz() from Module:ModuleName is available under the foo, bar, and baz variables respectively.

Replicated code

local foo = require('Module:ModuleName').foo
local bar = require('Module:ModuleName').bar
local baz = require('Module:ModuleName').baz

2

This option replicates a require() call and getting multiple fields from the module and setting that field name as a different variable from the respective method name. See the section below for the emulated code.

_G = loadLib(_G, {
    { 'Module:ModuleName', values={ qux='foo', lorem='bar', ipisum='baz' }
    -- Any other modules to load go here
})

Once this code is added, the methods foo(), bar(), and baz() from Module:ModuleName is available under the qux, lorem, and ipisum variables respectively.

Replicated code

local qux = require('Module:ModuleName').foo
local lorem = require('Module:ModuleName').bar
local ipisum = require('Module:ModuleName').baz

3

This option uses the value field in the two methods above, but adds a key. This will load the library into the global table besides the values. See the section below for the emulated code.

_G = loadLib(_G, {
    moduleName = { 'Module:ModuleName', values={ qux='foo', lorem='bar', ipisum='baz' }
    -- Any other modules to load go here
})

Once this code is added, the methods foo(), bar(), and baz() from Module:ModuleName is available under the qux, lorem, and ipisum variables respectively. Also, all methods of Module:ModuleName are available under the variable moduleName.

Replicated code

local moduleName = require('Module:ModuleName')
local qux = moduleName.foo
local lorem = moduleName.bar
local ipisum = moduleName.baz

Submodules


See Also

Hypixel SkyBlock Wiki Standard Lua Libraries (hsw/stdll) v · d · e
Type Libraries
Module Loading Utilities
General Utilities
Meta Modules
Object-oriented
Caching