Module:ModDisplay

From Caves of Qud Wiki
Revision as of 20:19, 27 October 2019 by Teamtoto (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

function p.main(frame)
  local rawmodlist = frame
  if frame.args ~= nil then
    rawmodlist = frame.args[1]
  end

  local modlist = ""
  local table = 'Mods'
  local fields = 'DisplayName'
  
  --separate the mods into an array...
  rawmodlist = rawmodlist:gsub('</br>', '&')

  for mod in rawmodlist:gmatch('%s*(%w+)%s*&?') do 
     local result = cargo.query(table, fields, {where='_pageNamespace="0" AND _pageName="'.. mod ..'"'})
     if not next(result) then
        return
     else
       modlist = modlist .. result[1]['DisplayName'] .. " "
     end
  end
  
  return (modlist)
  
end

return p