请输入您要查询的百科知识:

 

词条 Module:Loader/doc
释义

  1. Usage 1

      Example  

  2. Usage 2

      Example  
{{Module rating|b}}

This metamodule helps with loading of another module. That module is loaded only after one of its functions is called for the first time. This prevents it from being recorded as used on a given page if none of its functions is actually called.

{{TOC limit|2}}

Usage 1

local Loader = require('Module:Loader') -- Prefix 'Module:' is mandatory

local MyModule = Loader.load('Module:MyModule') -- Prefix 'Module:' is optional

Example

local Loader = require('Module:Loader')

local Math = Loader.load('Math')

return Math._random(10)

In this case Math is loaded when Math._random is accessed for the first time.

Usage 2

local load = require('Module:Loader').load -- Prefix 'Module:' is mandatory

local myFunction = load('Module:MyModule', 'myFunction') -- Prefix 'Module:' is optional

Example

local load = require('Module:Loader').load

local random = load('Math', '_random')

return random(10)

In this case Math is loaded when random(10) is called for the first time.

{{#ifeq:{{SUBPAGENAME}}|sandbox | |

}}

1 : Lua metamodules

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/27 10:29:11