Module:Lua banner

From Illogicopedia
Jump to navigation Jump to search


This module depends on the following module(s):
* Module:Lua banner/config

This module provides a stylized template used for informing others about the module used by a template or a module.

This module implements {{Lua}}

This module automatically change template to module if the namespace is module. Its also adds a tracking categories, for template: Category:Lua based templates, for module: Category:Modules depending on other Lua modules, for errors: Category:Lua banner errors. NOTE: Parameters are limited to 4.

Usage[edit source]

{{#invoke:Lua banner|main|module1|module2|module3|...}}

Use

{{#invoke:Lua|module1|module2|module3}}

Example[edit source]

{{#invoke:Lua banner|main|Module:Lua banner/config|||}}

Will output:



This module depends on the following module(s):
* Module:Lua banner/config

{{Lua|Module:Lua banner/config}} will give thesame result.

It is recomended that {{Lua}} be used instead.

local p = {}
local cfg = mw.loadData('Module:Lua banner/config')
local format = mw.ustring.format
local function err(msg)
return format("%s ¤%s [[%s]]", cfg["image"], msg, cfg["category"].err)
end
function p.main(frame)
a = frame.args
t = mw.title.getCurrentTitle()
mList = ''
if a[1] then
mList = "* [["..a[1].."]]"
else
return err('No value specified')
end
if a[2] == "" or nil then
else
mList = "* [["..a[1].."]]<br>* [["..a[2].."]]"
end
if a[3] == "" or nil then
else
mList = "* [["..a[1].."]]<br>* [["..a[2].."]]<br>* [["..a[3].."]]"
end
if a[4] == "" or nil then
else
mList = "* [["..a[1].."]]<br>* [["..a[2].."]]<br>* [["..a[3].."]]<br>* [["..a[4].."]]"
end
if a[5] then
return err("Out of limit")
end
if t.nsText == "Module" then
return format("%s %s %s <hr> [[%s]]", cfg["image"], cfg["text"].module, mList, cfg["category"].module)
else return format("%s %s %s <hr> [[%s]]", cfg["image"], cfg["text"].template, mList, cfg["category"].template)
end
end
return p