Module:HousingTable

From Eco - English Wiki
Revision as of 01:44, 25 February 2021 by Avaren (talk | contribs) (Avaren moved page Module:TaggedItemTable to Module:HousingTable without leaving a redirect)

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