Module:Lua: Difference between revisions

From Path of Exile Wiki
Jump to navigation Jump to search
(The wrappers feature of getArgs can now be used)
>OmegaK2
m (changed so that it only adds the category if it's not a doc page)
Line 2: Line 2:
local getArgs
local getArgs
local messageBox = require('Module:Message box')._main
local messageBox = require('Module:Message box')._main
local util = require('Module:Util')


function p.main(frame)
function p.main(frame)
Line 26: Line 27:
image = 'Lua programming language logo.svg',
image = 'Lua programming language logo.svg',
text = 'Uses Lua:\n' .. table.concat(modules, '\n')
text = 'Uses Lua:\n' .. table.concat(modules, '\n')
}) .. '[[Category:Lua-based templates]]'
}) .. util.misc.add_category('Lua-based templates', 10)
end
end


return p
return p

Revision as of 11:51, 1 September 2015

Module documentation[view] [edit] [history] [purge]

Lua error in package.lua at line 80: module 'Module:Message box' not found.

Implements {{Lua}}.

This module was adapted from Module:Lua banner on Wikipedia.
Adaptation is noted for reference and attribution only. This module may differ from the original in function or in usage. The documentation on Wikipedia may be helpful in understanding this module.

local p = {}
local getArgs
local messageBox = require('Module:Message box')._main
local util = require('Module:Util')

function p.main(frame)
	if not getArgs then
		getArgs = require('Module:Arguments').getArgs
	end
	local args = getArgs(frame, {
		wrappers = 'Template:Lua',
		trim = false
	})
	return p._main(args)
end

function p._main(args)
	local modules = {}
	for k, v in pairs(args) do
		if type(k) == 'number' and k >= 1 and math.floor(k) == k and string.find(v, '%S') then
			table.insert(modules, '* [[:' .. mw.text.trim(v) .. ']]')
		end
	end
	return messageBox({
		type	= 'notice',
		small	= true,
		image	= 'Lua programming language logo.svg',
		text	= 'Uses Lua:\n' .. table.concat(modules, '\n')
	}) .. util.misc.add_category('Lua-based templates', 10)
end

return p