Module:HousingTable: Difference between revisions
From Eco - English Wiki
[unchecked revision] | [unchecked revision] |
(Created page with "local p = {} -- local Utils = require('Module:Utils') function normaliseArgs(frame) local origArgs = frame:getParent().args local args = {} for k, v in pairs(origAr...") |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local Utils = require('Module:Utils') | |||
function | function p.table(frame) | ||
local args = Utils.normaliseArgs(frame) | |||
local | |||
if args.category == nil and args.type == nil then | |||
for | return 'category or type are required arguments' | ||
end | |||
local ItemData = mw.loadData("Module:ItemData") | |||
local returnStr = [[<table class="wikitable sortable jquery-tablesorter"> | |||
<thead><tr> | |||
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">Item</th> | |||
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">Type</th> | |||
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">Value</th> | |||
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">Dim. Return %</th> | |||
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">Dimensions</th> | |||
</tr></thead><tbody>]] | |||
for itemName, item in pairs(ItemData.items) do | |||
if (args.category == nil or args.category == item.roomCategory) and (args.type == nil or args.type == item.furnitureType) then | |||
mw.log(itemName) | |||
returnStr = returnStr .. '<tr><td>' .. itemName .. '</td><td>' .. item.furnitureType .. '</td><td>' .. item.skillValue .. '</td><td>' .. item.repeatsDepreciation .. '</td><td>' .. item.footprint .. '</td></tr>' | |||
end | |||
end | end | ||
return returnStr .. '</tbody><tfoot></tfoot></table>' | |||
end | end | ||
return p | return p |
Revision as of 01:44, 25 February 2021
Documentation for this module may be created at Module:HousingTable/doc
local p = {}
local Utils = require('Module:Utils')
function p.table(frame)
local args = Utils.normaliseArgs(frame)
if args.category == nil and args.type == nil then
return 'category or type are required arguments'
end
local ItemData = mw.loadData("Module:ItemData")
local returnStr = [[<table class="wikitable sortable jquery-tablesorter">
<thead><tr>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">Item</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">Type</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">Value</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">Dim. Return %</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">Dimensions</th>
</tr></thead><tbody>]]
for itemName, item in pairs(ItemData.items) do
if (args.category == nil or args.category == item.roomCategory) and (args.type == nil or args.type == item.furnitureType) then
mw.log(itemName)
returnStr = returnStr .. '<tr><td>' .. itemName .. '</td><td>' .. item.furnitureType .. '</td><td>' .. item.skillValue .. '</td><td>' .. item.repeatsDepreciation .. '</td><td>' .. item.footprint .. '</td></tr>'
end
end
return returnStr .. '</tbody><tfoot></tfoot></table>'
end
return p