Anonymous

Module:Sandbox/Skills/Cartography: Difference between revisions

From Melvor Idle
Sortable tables, switched to mw.html
No edit summary
(Sortable tables, switched to mw.html)
Line 226: Line 226:


-- Build the table
-- Build the table
local resultTable = {}
local resultTable = mw.html.create('table')
table.insert(resultTable, '==POI Discovery Rewards==\r\n')
resultTable:addClass('wikitable'):addClass('sortable')
table.insert(resultTable, '{| class="wikitable" style="text-align:left"')
resultTable:tag('tr'):addClass('headerRow-0')
table.insert(resultTable, '|-\r\n!|Point of Interest!!X!!Y!!Requirements!!Discovery Rewards')
:tag('th'):wikitext('Point of Interest'):done()
:tag('th'):wikitext('X'):done()
:tag('th'):wikitext('Y'):done()
:tag('th'):wikitext('Requirements'):done()
:tag('th'):wikitext('Discovery Rewards'):done()
 
for _, POI in ipairs(POIs) do
for _, POI in ipairs(POIs) do
table.insert(resultTable, '\r\n|-\r\n')
local X, Y = p.convertAxialToXY(POI.coords)
local X, Y = p.convertAxialToXY(POI.coords)
--Add Icon, Name, X and Y
local tr = mw.html.create('tr')
table.insert(resultTable, '||'..Icons.Icon({POI.name, type='poi'}))
tr:tag('td'):wikitext(Icons.Icon({POI.name, type='poi'}))
table.insert(resultTable, '||'..X..'||'..Y..'||')
tr:tag('td'):wikitext(X)
tr:tag('td'):wikitext(Y)
--Add Requirements
tr:tag('td'):wikitext(table.concat(p._getPOIRequirements(POI), '<br/>'))
local reqTable= p._getPOIRequirements(POI)
tr:tag('td'):wikitext(table.concat(p._getDiscoveryRewards(POI), '<br/>'))
table.insert(resultTable, table.concat(reqTable, '<br/>'))
resultTable:node(tr)
--Add Discovery Rewards
table.insert(resultTable, '||')
local rewardTable = p._getDiscoveryRewards(POI)
table.insert(resultTable, table.concat(rewardTable,'<br/>'))
end
end
table.insert(resultTable, '\n|}')
return tostring(resultTable)
return table.concat(resultTable)
end
end