Module:DispStructCostList
Jump to navigation
Jump to search
The above documentation is transcluded from Module:DispStructCostList/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 codeNameData = {}
local codeNameList = {}
if(args.BuildCost) then
--Extract our codename and cost prefix from the format 'CodeNameString:PrefixCost,CodeNameString:PrefixCost', ect
for item in args.BuildCost:gmatch("[^,]+") do
local codeName, quantity = item:match("(%a+):?(%d*)")
if codeName then
codeNameData[codeName] = codeNameData[codeName] or {}
if quantity then
codeNameData[codeName].prefix = quantity
end
table.insert(codeNameList, "'" .. codeName .. "'")
end
end
--If we have valid data parse that and our query through to the DispItemList module to return our build ItemDisp HTML
if next(codeNameData) ~= nil then
local itemQuery = {
tables = 'itemdata',
fields = 'CodeNameString,IsReleasedAndEnabled',
optionals = {where = "CodeNameString IN (" .. table.concat(codeNameList, ", ") .. ")"}
}
return require('Module:DispItemList').main({codeNames = codeNameData, query = itemQuery})
end
end
end
return p