Module:Store locations list: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 12: Line 12:
local yesNo = require("Module:Yesno")
local yesNo = require("Module:Yesno")
local purge = require("Module:Purge")._purge
local purge = require("Module:Purge")._purge
local inspect = require("Module:Inspect")


local p2pIcon = '[[File:Member icon.png|frameless|link=Pay-to-play]]'
local p2pIcon = '[[File:Member icon.png|frameless|link=Pay-to-play]]'
Line 20: Line 21:
end
end


function dump(o)
if type(o) == 'table' then
  local s = '{ '
  for k,v in pairs(o) do
  if type(k) ~= 'number' then k = '"'..k..'"' end
  s = s .. '['..k..'] = ' .. dump(v) .. ','
  end
  return s .. '} '
else
  return tostring(o)
end
end


function p._main(args)
function p._main(args)
Line 76: Line 65:
     -- Create the rows for the output table
     -- Create the rows for the output table
     for _, shop in ipairs(data) do
     for _, shop in ipairs(data) do
     mw.log("shop", dump(shop))
     mw.log("shop", inspect(shop))
    
    
     for i, location in ipairs(shop.location) do
     for i, location in ipairs(shop.location) do
Line 122: Line 111:
     mw.log(string.format('SMW (store locations list): entries: %d, time elapsed: %.3f ms.', #smwdata, (t2 - t1) * 1000))
     mw.log(string.format('SMW (store locations list): entries: %d, time elapsed: %.3f ms.', #smwdata, (t2 - t1) * 1000))
      
      
     mw.log("smw data", dump(smwdata))
     mw.log("smw data", inspect(smwdata))


     table.sort(smwdata, function(a, b) return b['Store sell price'] < a['Store sell price'] end)
     table.sort(smwdata, function(a, b) return b['Store sell price'] < a['Store sell price'] end)
Line 171: Line 160:
         local dataline = p.processData(item, editbtn)
         local dataline = p.processData(item, editbtn)


mw.log("dataline", dump(dataline))
mw.log("dataline", inspect(dataline))


         table.insert(data, dataline)
         table.insert(data, dataline)
Line 248: Line 237:
     local members = item['Members']
     local members = item['Members']
mw.log("members", members)
mw.log("members", members)
mw.log("members dump", dump(members))
mw.log("members dump", inspect(members))
     if type(members) == 'table' then
     if type(members) == 'table' then
         -- contains yes and/or no
         -- contains yes and/or no

Navigation menu