Module:DispToolList
Aller à la navigation
Aller à la recherche
The above documentation is transcluded from Module:DispToolList/doc.[edit | history | purge]
local p = {}
function p.main(frame)
local args = frame
if frame == mw.getCurrentFrame() then
args = require('Module:ProcessArgs').merge(true)
else
frame = mw.getCurrentFrame()
end
local itemDispData = {}
local codeNameList = {}
if(args.ToolTypes) then
for toolType in args.ToolTypes:gmatch("[^,]+") do
local toolQuery = {
tables = 'tools',
fields = 'CodeNameString',
optionals = {where = "ToolTypes HOLDS '"..toolType.."' "}
}
--Query for any tools matching this tooltype
local result = mw.ext.cargo.query(toolQuery.tables, toolQuery.fields, toolQuery.optionals)
if(#result > 0) then
for i, row in ipairs(result) do
local itemCodeName = row['CodeNameString']
if itemCodeName then
--Look for dupe codenames in our table
local hasMatch = false
for key, value in pairs(itemDispData) do
if key == itemCodeName then
hasMatch = true
break
end
end
-- Add our codename to the disp pool if its valid
if not hasMatch then
itemDispData[itemCodeName] = itemDispData[itemCodeName] or {}
-- itemDispData[itemCodeName].prefix = ''
table.insert(codeNameList, "'" .. itemCodeName .. "'")
end
end
end
end
end
--Handle our codename list and parse through to the base module for output
if #codeNameList >0 then
local itemQuery = {
tables = 'itemdata',
fields = 'CodeNameString,IsReleasedAndEnabled',
optionals = {where = "CodeNameString IN (" .. table.concat(codeNameList, ", ") .. ")"}
}
return require('Module:DispItemList').main({codeNames = itemDispData, query = itemQuery})
end
end
end
return p