Module:ListLightSources

local p = {} local cargo = mw.ext.cargo

-- Print the list of all tenants in the game. (based on Special:CargoTables/tenant) -- Usage: - everything except blocks and liquids -- or, or function p.ListLights( frame ) local itemCategory = frame.args[1] local where = 'category NOT IN ("block", "liquid")'

if itemCategory == "block" or itemCategory == "liquid" then where = 'category="' .. itemCategory .. '"' end

where = where .. ' AND prop="lightLevel"'

-- Perform a SQL query to the Cargo database. local tables = 'item_metadata,item' local fields = 'name,wikiPage,value=lightLevel' local queryOpt = { limit = 5000, where = where, orderBy = '(0+lightLevel) DESC', join = 'item_metadata.id=item.id' }

local rows = cargo.query( tables, fields, queryOpt ) or {} if #rows == 0 then -- Nothing found. return '' end

-- Show a table of all light sources. -- Resistances must be in the same order as displayed in-game. local ret = '{| class="wikitable sortable"\n' .. '|-\n! Item !! Light level !! Light color\n'

for _, row in ipairs( rows ) do ret = ret .. '|-\n| ' .. row.name .. ' ||' .. row.lightLevel .. '|| TODO: light color\n' end

ret = ret .. '\n|}' return ret end

return p