(Created page with "local Flags = require('Module:Flags') local pFlag = {} local cargo = mw.ext.cargo function pFlag.makeFlag(flagArg, playerId, gameCategory) -- Look up Cargo table for nationality string if flagArg then return Flags.icon( flagArg, gameCategory) end local tables = 'People' local fields = '_pageName, nationality' local cargoArgs = { where = '_pageName = "' .. playerId .. '"' } local results = cargo.query(tables, fields, cargoArgs) if #results > 0 then retur...") |
mNo edit summary |
||
(8 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
return Flags.icon( flagArg, gameCategory) | return Flags.icon( flagArg, gameCategory) | ||
end | end | ||
playerId = string.gsub(playerId, '_', ' ') | |||
local tables = 'People' | local tables = 'People' | ||
local fields = '_pageName, nationality' | local fields = '_pageName, nationality' | ||
local cargoArgs = { | local cargoArgs = { | ||
where = '_pageName = "' .. playerId .. '"' | where = '_pageName="' .. playerId .. '"' | ||
} | } | ||
local results = cargo.query(tables, fields, cargoArgs) | local results = cargo.query(tables, fields, cargoArgs) |
Latest revision as of 11:43, 3 October 2023
Documentation for this module may be created at Module:Person/Flag/doc
local Flags = require('Module:Flags')
local pFlag = {}
local cargo = mw.ext.cargo
function pFlag.makeFlag(flagArg, playerId, gameCategory)
-- Look up Cargo table for nationality string
if flagArg then
return Flags.icon( flagArg, gameCategory)
end
playerId = string.gsub(playerId, '_', ' ')
local tables = 'People'
local fields = '_pageName, nationality'
local cargoArgs = {
where = '_pageName="' .. playerId .. '"'
}
local results = cargo.query(tables, fields, cargoArgs)
if #results > 0 then
return Flags.icon( mw.text.split(results[1].nationality, ',')[1], gameCategory)
else
return nil
end
end
return pFlag