Module:LocLine: Difference between revisions
Jump to navigation
Jump to search
m (no preprocess pls) |
m (1 revision imported) |
(No difference)
|
Latest revision as of 21:22, 4 November 2021
Documentation for this module may be created at Module:LocLine/doc
local p = {}
local editBtn = '<small>' .. require('Module:Edit button')() .. '</small>'
local yesno = require('Module:Yesno')
local isEmpty = require('Module:Paramtest').is_empty
function p.main(frame)
local membscol = {
[true] = '[[File:P2P icon.png|30px|link=Pay-to-play]]',
[false] = '[[File:F2P icon.png|30px|link=Free-to-play]]',
}
local args = frame:getParent().args
local loc = args.loc or '? ' .. editBtn
local levels = args.lvls or '? ' .. editBtn
local membs = membscol[yesno(args.mem ~= nil and args.mem or "no")]
local mapID = args.mapID
local plane = args.plane
local name = args.name or mw.title.getCurrentTitle().text
local spawns
local map
local ret = mw.html.create('tr')
if(isEmpty(loc)) then loc = '? ' .. editBtn end
if(isEmpty(levels)) then levels = '? ' .. editBtn end
-- build up {{Maplink}} string to be preprocess()'d
map = '{{Maplink|mtype=pin|icon=redPin|desc=' .. name
if mapID then
map = map .. '|mapID=' .. mapID
end
if plane then
map = map .. '|plane=' .. plane
end
local i = 1
while args[i] do
map = map .. '|' .. args[i]
-- add "NPC ID: ####" pin descriptions only if description not already provided
if not string.find(args[i], 'desc:') then
local desc = ''
local npcid = string.match(args[i], 'npcid:(%d+)')
if npcid then
desc = 'NPC ID: ' .. npcid
end
map = map .. ',desc:' .. desc
end
i = i + 1
end
spawns = i - 1
if args.nopreprocess then
map = map .. '|nopreprocess=t'
end
map = map .. '}}'
-- build table row to return
-- column order (from {{LocTableHead}}): Location, Levels, Members, Spawns, Map
ret
:tag('td'):wikitext(loc):done()
:tag('td'):wikitext(levels):done()
:tag('td'):wikitext(membs):done()
:tag('td'):wikitext(tostring(spawns)):done()
:tag('td'):wikitext(frame:preprocess(map)):done()
return ret
end
return p