Module:GenerateDescription/Person: Difference between revisions

From TwogPedia
(Created page with "local getArgs = require('Module:Arguments').getArgs local p = {} function p.main(frame) end function p.temp(frame) local args = getArgs(frame) local currentTitle = mw.title.getCurrentTitle().text local currentTitleSplit = mw.text.split(currentTitle, '/') local game = currentTitleSplit[1] local div = mw.html.create('div') local org = args.org and (' is the ' .. game .. ' team of Companies/' .. args.org .. '') or ' a ' .. game .. ' team' local founde...")
 
mNo edit summary
Line 1: Line 1:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local cargo = mw.ext.cargo
local p = {}


local p = {}


function p.main(frame)
function p.main(frame)
end
function p.temp(frame)
   local args = getArgs(frame)
   local args = getArgs(frame)
   local currentTitle = mw.title.getCurrentTitle().text
   local currentTitle = mw.title.getCurrentTitle().text
   local currentTitleSplit = mw.text.split(currentTitle, '/')
   local currentTitleSplit = mw.text.split(currentTitle, '/')
  local game = currentTitleSplit[1]


  -- Check if
  local tables = 'Transfers'
  local fields = '_pageName, position'
  local cargoArgs = {
where = 'id= "' .. mw.title.getCurrentTitle().text .. '" AND leavedate IS NULL AND inactivedate IS NULL'
  }
  transferResults = cargo.query(tables, fields, cargoArgs)
 
  local name = args.romanized and args.romanized or args.name and args.name or (args.title or '')
  -- Find the position of the first space in the name
  local firstSpaceIndex = string.find(name , " ")
  -- If a space is found, insert the title before it
  if firstSpaceIndex then
    name = string.sub(name, 1, firstSpaceIndex) .. '"' .. args.title .. '" ' .. string.sub(name, firstSpaceIndex + 1)
  end
 
   local div = mw.html.create('div')
   local div = mw.html.create('div')
   local org = args.org and (' is the ' .. game .. ' team of [[Companies/' .. args.org .. ']]') or ' a ' .. game .. ' team'
   local str = name
   local founded = args.founded and (' that was founded on ' .. args.founded ) or ''
  if args.birthdate then str = str .. ', born on ' .. args.birthdate .. ',' end
  local region = args.region and ('They compete in the ' .. args.region .. ' region') or ''
  if args.active_roles then str = str .. ' is a ' .. active_roles end
   local roster = args.roster and ( args.region and (' and have a ' .. args.roster .. ' roster ' ) or ('They have a ' .. args.roster .. ' roster') ) or ''
   if args.nationality then str = str .. (args.active_roles and ' from ' or ' is from ' ) .. args.nationality end
   div:wikitext(mw.ext.displaytitle.get(currentTitle) .. org  .. founded .. '. ' .. region .. roster)
   if #transferResults > 0 then
    str = str .. ' and is currently fulfilling the position of ' .. transferResults[1].position.. ' in [[' .. transferResults[1]._pageName .. ']]'
  end
  str = str .. '.'
   div:wikitext(str)


   return div
   return div

Revision as of 17:04, 30 April 2024

Documentation for this module may be created at Module:GenerateDescription/Person/doc

local getArgs = require('Module:Arguments').getArgs
local cargo = mw.ext.cargo
local p = {}


function p.main(frame)
  local args = getArgs(frame)
  local currentTitle = mw.title.getCurrentTitle().text
  local currentTitleSplit = mw.text.split(currentTitle, '/')

  -- Check if 
  local tables = 'Transfers'
  local fields = '_pageName, position'
  local cargoArgs = {
	where = 'id= "' .. mw.title.getCurrentTitle().text .. '" AND leavedate IS NULL AND inactivedate IS NULL'
  }
  transferResults = cargo.query(tables, fields, cargoArgs)	
  
  local name = args.romanized and args.romanized or args.name and args.name or (args.title or '')
  -- Find the position of the first space in the name
  local firstSpaceIndex = string.find(name , " ")
  -- If a space is found, insert the title before it
  if firstSpaceIndex then
    name = string.sub(name, 1, firstSpaceIndex) .. '"' .. args.title .. '" ' .. string.sub(name, firstSpaceIndex + 1)
  end
  
  local div = mw.html.create('div')
  local str = name
  if args.birthdate then str = str .. ', born on ' .. args.birthdate .. ',' end
  if args.active_roles then str = str .. ' is a ' .. active_roles end
  if args.nationality then str = str .. (args.active_roles and ' from ' or ' is from ' ) .. args.nationality end
  if #transferResults > 0 then
    str = str .. ' and is currently fulfilling the position of ' .. transferResults[1].position.. ' in [[' .. transferResults[1]._pageName .. ']]'
  end
  str = str .. '.'
  div:wikitext(str)

  return div
end

return p