Module:Store locations list: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 36: Line 36:
     -- Get parsed smw data
     -- Get parsed smw data
     local data = p.getData(item, limit)
     local data = p.getData(item, limit)
mw.log("data", dump(data), '\n\n\n')


     -- Create the header of the output
     -- Create the header of the output
Line 54: Line 52:
     -- 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), '\n\n\n')
     for i, location in ipairs(shop.location) do
     for i, location in ipairs(shop.location) do
        restbl:tag('tr')
        restbl:tag('tr')
Line 72: Line 68:
end
end
     end
     end
mw.log("restbl", tostring(restbl))


     return headerText .. tostring(restbl)
     return headerText .. tostring(restbl)
Line 110: Line 104:


     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)
mw.log("smwdata", dump(smwdata))


     -- Iterate through each shop instance of item
     -- Iterate through each shop instance of item
Line 146: Line 138:
         end
         end


mw.log("First item", dump(item), '\n\n\n')


         -- Loop over smw return items
         -- Loop over smw return items
Line 154: Line 145:
         local dataline = p.processData(item, editbtn)
         local dataline = p.processData(item, editbtn)


mw.log("dataline", dump(dataline), '\n\n\n')




Line 182: Line 172:
      
      
     local currency = item['Store currency']
     local currency = item['Store currency']
   
    mw.log("item", dump(item))


     local sellvalue = item['Store sell price'] or ''
     local sellvalue = item['Store sell price'] or ''
     local sellSortValue = 0
     local sellSortValue = 0
mw.log("sellvalue 1", sellvalue)


     if not(sellvalue == 1e10) then
     if not(sellvalue == 1e10) then
         sellvalue = tonumber(sellvalue)
         sellvalue = tonumber(sellvalue)
mw.log("Sell value 2", sellvalue)


         if sellvalue then
         if sellvalue then
             sellSortValue = sellvalue
             sellSortValue = sellvalue
             sellvalue = commas(sellvalue)
             sellvalue = commas(sellvalue)
mw.log("sellvalue", sellvalue)
             local currencyImg =  ''
             local currencyImg =  ''
             if(params.has_content(currencyImg)) then
 
                currencyImg = string.format('[[File:%s|link=%s]] ', currencyImg, currency)
sellvalue = string.format('%s [[%s]]', sellvalue, currency)
                sellvalue = currencyImg .. sellvalue
 
             end
             -- if(params.has_content(currencyImg)) then
            --    currencyImg = string.format('[[File:%s|link=%s]] ', currencyImg, currency)
            --    sellvalue = currencyImg .. sellvalue
             -- end
         else
         else
             sellvalue = editbtn    -- If sellvalue can't be converted to a number it will default to the edit button
             sellvalue = editbtn    -- If sellvalue can't be converted to a number it will default to the edit button

Navigation menu