Hypixel SkyBlock Wiki:Modules

Lua is a programming language that is available via the Scribunto wp:MediaWiki extension on the English The Hypixel Skyblock Wiki. Lua code can now be embedded into wiki templates by employing the "" functionality of Scribunto. This extension supports Lua 5.1 as of July 2015.

Running a module
Modules are run on normal wiki pages using the parser function. The syntax of #invoke is similar to template syntax, but with some differences. The most important difference is that you need to specify a function name. A function is a set of instructions that takes input values, processes them, and returns an output value. This is much like what a template does: you give it arguments, it processes them, and you get a result. However, you can define many functions in one Lua module, whereas you can only define one template on one page.

Furthermore, you can't just run a Lua module directly – you can only run one of the module's functions. The module is just a container for the functions, and doesn't do anything by itself. So there are two reasons that we need to input a function name: we can't run a module by itself, and without specifying a function name, Lua will not know which function it is we want to run.

Wiki-specific features
Overall: Lua can only get input as text strings passed to the  and what can be fetched via mw.title.new(...):getContent and frame:expandTemplate. Lua output will not be preprocessed unless frame:preprocess is explicitly called, meaning that template calls, parser functions, etc. in the output will not work correctly. Also, all Lua in the page is limited to 10 seconds CPU time (you can look in the source code of a rendered page to see how long a template or module took to parse). And relative to standard Lua, Scribunto's Lua lacks all sorts of functions (see mw:Extension:Scribunto/Lua reference manual § Differences from standard Lua).

Lua input limitations
Lua code in Scribunto is only run when the page is being parsed. Therefore, the only user input that Lua can receive is by page editing – it cannot create a box that calculates the square root of a number you type in, or recalculate a piece of the Mandelbrot set depending on which part of the parent set you click on. The input Lua can receive includes any transcludeable text page on The Hypixel Skyblock Wiki.

Wikitext
Transcluded The Hypixel Skyblock Wiki headers frequently contain a hidden code such as "UNIQ5ae8f2aa414ff233-h-3--QINU" which may need to be stripped out in order for them to be parsed effectively.

Wikilinks using the Pipe trick  won't work if returned as output – they need to be written explicitly as Help. Other pre-save transforms, such as replacing with signatures, will also fail to be processed. Template transclusions, parser function calls, and variable substitutions (i.e. anything with a ) will not be processed, nor will tags such as or.

Labeling converted templates
Please place the lua template on the documentation subpage of all templates that use Lua. It will help to better communicate Lua usage and template conversions.

Module Categories
Highly-visible modules (HVMs) are modules that are used for parsing a large amount of articles. Articles are the end product visible to readers, hence the name "highly-visible". These modules shall be kept operational and updated as much as possible. These modules may be semi or fully protected.
 * Highly-visible Modules

Meta-modules (MMs) are modules that are written with the purpose of use on other modules, usually assigned to perform high used routines. These modules can be choke-points for performance to their dependent modules, hence shall be kept operational, efficient, and updated as much as possible. These modules may be semi or fully protected.
 * Meta-modules

Caching
This wiki uses the Lua Caching technology for some data modules. Putting large data modules into site cache saves processing time. The cached data will require clicking a button to update.

To refresh cache for a data: This part requires RefreshLuaCache to be enabled in your gadget settings. Otherwise, no refresh handle will be loaded. This gadget is default off, so please check.

See if there is a "refresh cache" handle on the module page or on Module:Cache. Click on the button to refresh its cache.

Think of the datasheet as drawers we call "entries", with each entry associated with a key used to address the entry. We can put data into a data entry like we put things into a drawer.

Refreshing the cache will update all data in entries of existing keys, and add data entries for new keys; but it will not delete entries of existing keys that no longer exists, even when the key no longer exists in the data module that is being cached.

To hard refresh a cache: This part requires the user right to complete. Please find Staff Assistance if you need help.

To truly erase data entries of keys that no longer exist in a cached data module, one must use hard refresh. On Module:Cache, increase the corresponding PREFIX variable. For example, change slotaliases_01_ to slotaliases_02_.

This may cause a spike on Lua time for the following minute. Technically, the previous cache is not removed (only not used), but should be removed after some variable amount of time.

To hook a data module to cache: This part requires the user right to complete. Please find Staff Assistance if you need help.

Step 1: Edit Module:Cache. Example:

Step 2: Add page to supportedCaches on MediaWiki:Gadget-refreshLuaCache.js. Example:

Step 3: Add hooks. On Module:Cache/doc and other Module documentation pages you want to add a hook on, include this button:

Related extensions/scripts:
 * The VariablesLua and LuaCache extensions
 * MediaWiki:Gadget-refreshLuaCache.js
 * Module:Cache, Module:VarsCacheMap