Module:Matchup: Difference between revisions

From Wavu Wiki, the 🌊 wavy Tekken wiki
(Created page with "local p = {}; p.main = function(frame) local p1 = frame[1] local p2 = frame[2] return p._main(p1, p2) end p._main = function(p1, p2) if p1 == p2 then return '' end loca...")
 
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {};
local f = require("Module:Fighter")


p.main = function(frame)
local p = {}
local p1 = frame[1]
local p2 = frame[2]
return p._main(p1, p2)
end


p._main = function(p1, p2)
p._pageTitle = function(p1, p2)
if p1 == p2 then return '' end
local label = p2
local class = p2:lower():gsub("%s+","-")
if p1 > p2 then
if p1 > p2 then
p2, p1 = p1, p2
p2, p1 = p1, p2
end
end
local pageTitle = p1 .. " vs " .. p2
return p1 .. " vs " .. p2
return mw.getCurrentFrame():expandTemplate{
end
title = "CharSelectChar",
 
args = { label, class, pageTitle }
p._charSelect = function(pov)
}
r = ''
for _, oppo in ipairs(f.fighters) do
local label = oppo
local class = oppo:lower():gsub("%s+","-")
r = r .. mw.getCurrentFrame():expandTemplate{
title = "CharSelectChar",
args = { label, class, p._pageTitle(pov, oppo) }
}
end
return r
end
 
p.charSelect = function(frame)
local pov = frame.args[1]
return p._charSelect(pov)
end
 
-- A wikitext list of links to matchup pages that exist for this fighter,
-- for use in Template:Navbox matchup
p._navbox = function(pov)
r = ''
for _, oppo in ipairs(f.fighters) do
local pageTitle = p._pageTitle(pov, oppo)
local title = mw.title.new(pageTitle)
if title.exists then
r = r .. "* [[" .. pageTitle .. "|" .. oppo .. "]]\n"
end
end
return r
end
 
p.navbox = function(frame)
local pov = frame.args[1]
return p._navbox(pov)
end
end


return p
return p

Latest revision as of 14:35, 5 July 2021

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

local f = require("Module:Fighter")

local p = {}

p._pageTitle = function(p1, p2)
	if p1 > p2 then
		p2, p1 = p1, p2
	end
	return p1 .. " vs " .. p2
end

p._charSelect = function(pov)
	r = ''
	for _, oppo in ipairs(f.fighters) do
		local label = oppo
		local class = oppo:lower():gsub("%s+","-")
		r = r .. mw.getCurrentFrame():expandTemplate{
			title = "CharSelectChar",
			args = { label, class, p._pageTitle(pov, oppo) }
		}
	end
	return r
end

p.charSelect = function(frame)
	local pov = frame.args[1]
	return p._charSelect(pov)
end

-- A wikitext list of links to matchup pages that exist for this fighter,
-- for use in Template:Navbox matchup
p._navbox = function(pov)
	r = ''
	for _, oppo in ipairs(f.fighters) do
		local pageTitle = p._pageTitle(pov, oppo)
		local title = mw.title.new(pageTitle)
		if title.exists then
			r = r .. "* [[" .. pageTitle .. "|" .. oppo .. "]]\n"
		end
	end
	return r
end

p.navbox = function(frame)
	local pov = frame.args[1]
	return p._navbox(pov)
end

return p