Difference between revisions of "Module:HoVoTeamLookup"

From Furry Basketball Association
Jump to: navigation, search
m (Added logic to figure out a player's position from the roster/team template)
m
Line 1: Line 1:
 
local p = {}
 
local p = {}
  
function p.teamposition( frame )
+
function p.position( frame )
 
 
 
local pagedata = mw.title.new('Template:Roster/team'):getContent()
 
local pagedata = mw.title.new('Template:Roster/team'):getContent()
Line 31: Line 31:
  
 
return pos
 
return pos
 +
end
 +
 +
function p.team( frame )
 +
 +
local pagedata = mw.title.new('Template:Roster/team'):getContent()
 +
local teamsplit = mw.text.split(pagedata, '}}%s|')
 +
 +
return teamsplit[1], teamsplit[2], teamsplit[3]
 
end
 
end
  
 
return p
 
return p

Revision as of 17:08, 4 December 2019

local p = {} function p.position( frame ) local pagedata = mw.title.new('Template:Roster/team'):getContent() local seek = '=' .. frame.args[1] .. '\n' local idpos = string.find(pagedata, seek) local role = pagedata:sub(idpos-2, idpos-1) local pos = '' if role:sub(1, 1) == 'B' then pos = 'Bench' elseif role:sub(1, 1) == 'R' then pos = 'Reserve' elseif role:sub(1, 1) == 'D' then pos = 'Deep Reserve' elseif role == 'S1' then pos = 'Point Guard' elseif role == 'S2' then pos = 'Shooting Guard' elseif role == 'S3' then pos = 'Small Forward' elseif role == 'S4' then pos = 'Power Forward' elseif role == 'S5' then pos = 'Center' else pos = 'Unknown' end return pos end function p.team( frame ) local pagedata = mw.title.new('Template:Roster/team'):getContent() local teamsplit = mw.text.split(pagedata, '}}%s|') return teamsplit[1], teamsplit[2], teamsplit[3] end return p