VOOZH about

URL: https://minecraft.wiki/w/Module:Static

⇱ Module:Static – Minecraft Wiki


Module:Static

From Minecraft Wiki
Jump to navigation Jump to search
Documentation[view] [edit] [history] [purge]Jump to code ↴

Usage

This module returns a table that can store data that persists in between multiple {{#Invoke:}} calls.

Example:

localp={}

functionp.main()
localstatic=require('Module:Static')
static.x=(static.xor0)+1
returnstatic.x
end

returnp

If the above code sample was stored in Module:foo and then {{#Invoke:foo|main}} {{#Invoke:foo|main}} would result in 1 2.

Dev spec

Because data stored through this module can be invoked by any modules used in the same page. To avoid being interfered with by other modules, a module MUST store data in their own namespace (a sub-table, see below), and NEVER modify data in other namespace.

For example, in "Module:Example":

...
localstatic=require('Module:Static')
ifnotstatic.Examplethen
static.Example={}
end
static.Example.exampleData=3
...

Data stored by a module, must be stored in a sub-table with the same name of that module (capitalize the first letter, and all spaces replaced with underscores). This sub-table should being initialized immediately after the invocation of this module.

[view] [edit] [history] [purge]The above documentation is transcluded from Module:Static/doc.
-- Source: https://runescape.wiki/w/Module:Static
localmwHtml=getmetatable(mw.html.create())
mwHtml._static=mwHtml._staticor{}
returnmwHtml._static
Retrieved from "https://minecraft.wiki/w/Module:Static?oldid=2929222"

Navigation menu