Hypixel SkyBlock Wiki
Advertisement
Paper Nuavo.png This Page documents an Wiki Policy 
This Page is generally accepted by the community as a policy for the Wiki. Changes should reflect consensus or be approved by the Staff Team.
If you disagree with this Policy, please discuss it with the Staff Team or on its talk page.

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 "{{#invoke:}}" 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 {{#invoke}} 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.[1] 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 {{#invoke:}} 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 [[The Hypixel Skyblock Wiki:Help| ]] won't work if returned as output – they need to be written explicitly as [[The Hypixel Skyblock Wiki:Help|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 <ref>o</ref> or <nowiki>o</nowiki>.

Labeling converted templates[]

Lua icon.pngInvokes Lua:

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.

See also[]

Notes and References[]

  1. You can also have multiple output values, but functions that do this are not normally meant to be accessed from wiki pages.
Advertisement