Difference between revisions of "Module:HoVoTeamLookup"

From Furry Basketball Association
Jump to: navigation, search
m
m
Line 41: Line 41:
 
if idpos ~= nil then
 
if idpos ~= nil then
 
team = v
 
team = v
role = pagedata:sub(idpod+3, idpod+4)
+
role = pagedata:sub(idpos+3, idpos+4)
 
end
 
end
 
end
 
end

Revision as of 19:46, 4 December 2019

local p = {} function p.newposition( frame ) local teams = { "ALB", "ALK", "AZW", "BAL", "BGR", "BLV", "DAK", "EDM", "HNT", "HWI", "LOR", "LVG", "MON", "PIT", "PLY", "QNS", "SAS", "SEA", "SJT", "TAL", "TEN", "TXS", "WIL", "WPG" } local seek = '=' .. frame.args[1] .. '\n' local team = '' local role = '' for i, v in ipairs(teams) do local page = 'Lineup/' .. v local pagedata = mw.title.new(page):getContent() local idpos = string.find(pagedata, seek) if idpos ~= nil then team = v role = pagedata:sub(idpos+3, idpos+4) end end local pos = '' if role == '01' then pos = 'Point Guard' elseif role == '02' then pos = 'Shooting Guard' elseif role == '03' then pos = 'Small Forward' elseif role == '04' then pos = 'Power Forward' elseif role == '05' then pos = 'Center' elseif role == '06' then pos = '1st Bench' elseif role == '07' then pos = '2nd Bench' elseif role == '08' then pos = '3rd Bench' elseif role == '09' then pos = '4th Bench' elseif role == '10' then pos = '5th Bench' elseif role == '11' then pos = '6th Bench' elseif role == '12' then pos = '7th Bench' elseif role == 'DN' then pos = 'DNP' else pos = 'Unknown' end return pos end 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 seek = '=' .. frame.args[1] .. '\n' local teamsplit = mw.text.split(pagedata, '%s}}%s') local team = 0 for i, v in ipairs(teamsplit) do if string.match(v, seek) then team = i end end local equalpos = string.find(teamsplit[team], ' = ') - 1 local teamname = '' if team == 1 then teamname = string.sub(teamsplit[team], 34, equalpos) elseif team == 0 then teamname = 'Unknown' else teamname = string.sub(teamsplit[team], 2, equalpos) end return teamname end return p