Module:Sandbox/Botanist/CharacterWeapons
Jump to navigation
Jump to search
Lua error at line 93: attempt to index global 'chartiers' (a nil value).
local p = {}
function p.fetchCharacters(frame)
local argList = {
'%PAGE%',
'name',
'jpname',
'rarity',
'type',
'element',
'race',
'weapon',
'charid',
'id'
}
local params = {
category = 'Characters',
include = '{Character}:' .. table.concat(argList, ':'),
mode = 'userformat',
secseparators = '====',
multisecseparators = '===='
}
local data = frame:callParserFunction('#dpl:', params)
argList[1] = 'link'
return p.indexDPLTable(frame, argList, data)
end
function p.indexDPLTable(frame, argList, data)
local pagenames = {}
pagenames[frame:getTitle()] = true
local pf = frame:getParent()
while (pf ~= nil) and (pf ~= pf:getParent()) do
pagenames[pf:getTitle()] = true
pf = pf:getParent()
end
local result = {}
local ix = 1
for row in mw.text.gsplit(data, '====', true) do
local found_value = false
local args = {}
local i = 0
for arg in mw.text.gsplit(row, '\n|') do
i = i+1
if (arg ~= '') and (arg ~= nil) then
local key = argList[i]
args[key] = arg
found_value = true
end
end
ix = ix + 1
args.ix = ix
if found_value then
if pagenames[args['name']] ~= nil then
args['name'] = args['link']
end
table.insert(result, args)
end
end
return result
end
function printCell(contents)
if contents ~= nil then
table.insert(result, '<td>'..contents..'</td>')
else
table.insert(result, '<td style="background-color: red;">???</td>')
end
end
function p.makeCharacterReport(frame)
local temp = p.fetchCharacters(frame)
-- index by link
local characters = {}
for key,value in pairs(temp) do
characters[value.link] = value
end
local result = {}
table.insert(result, '<table class="wikitable sortable jquery-tablesorter">')
table.insert(result, '<tr>')
table.insert(result, '<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">id</th>')
table.insert(result, '<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">cid</th>')
table.insert(result, '<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">wpns</th>')
table.insert(result, '<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">jpname</th>')
table.insert(result, '<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">link</th>')
table.insert(result, '<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">name</th>')
table.insert(result, '<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">r</th>')
table.insert(result, '<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">el</th>')
table.insert(result, '<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">ty</th>')
table.insert(result, '<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">ra</th>')
table.insert(result, '</tr>')
for link,character in pairs(characters) do
local chartier = chartiers[link]
table.insert(result, '<tr>')
printCell(chartier.id)
printCell(chartier.charid)
printCell(chartier.weapon)
printCell(chartier.jpname)
table.insert(result, '<td>[['..character.link..']]</td>')
printCell(chartier.name)
printCell(chartier.rarity)
printCell(chartier.element)
printCell(chartier.type)
printCell(chartier.race)
table.insert(result, '</tr>')
end
table.insert(result, '</table>')
return table.concat(result, '\n')
end
return p