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')
local Utils = require('Module:Utils')


function normaliseArgs(frame)
function p.table(frame)
  local origArgs = frame:getParent().args
local args = Utils.normaliseArgs(frame)
   local args = {}
 
    
if args.category == nil and args.type == nil then
   for k, v in pairs(origArgs) do
return 'category or type are required arguments'
   mw.log(k)
end
  mw.log(v)
 
    v = mw.text.trim(tostring(v))
   local ItemData = mw.loadData("Module:ItemData")
    if v ~= '' then
 
      args[k] = v
   local returnStr = [[<table class="wikitable sortable jquery-tablesorter">
    end
<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 args
end


function p.table(frame)
  return returnStr .. '</tbody><tfoot></tfoot></table>'
local args = normaliseArgs(frame)


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