Module:WorldData

local private = {} local public = {}

function private.trimWhitespace(str) local _start = 1 while (str:sub(_start, _start) == " ") do       _start = _start + 1 end local _end = str:len while (str:sub(_end, _end) == " ") do       _end = _end - 1 end return str:sub(_start, _end) end

function private.processCsv(csv) local retval = {} for arg in csv:gmatch("([^,]+)") do		table.insert(retval, private.trimWhitespace(arg)) end return retval end

function public.World(frame) local args = frame:getParent.args local world = args["world"] local tabber = mw.html.create("div") tabber:addClass("tabberex") if world == nil then world = "?" end for k, v in ipairs(args) do		local template_params = private.processCsv(args[k]) local template_call = frame:expandTemplate{title = "TutorialSong", args = template_params} tabber:tag("div") :addClass("tabberex-tab") :attr("data-tab-header", world .. "-" .. k) :wikitext("\n" .. template_call .. "\n") :done end if args["x"] ~= nil then local x_params = private.processCsv(args["x"]) local x_call = frame:expandTemplate{title = "BossSong", args = x_params} local x_header = world .. "-X" local x_icon = args["x_icon"] if x_icon == nil then x_icon = x_header .. " Icon.png" end local icon_title = mw.title.new("File:" .. x_icon) if icon_title["fileExists"] then x_header = "" .. x_header end tabber:tag("div") :addClass("tabberex-tab") :addClass("tabberex-tab-default") :tag("span") :addClass("tabberex-tab-header") :wikitext(x_header) :done :wikitext("\n" .. x_call .. "\n") :allDone end return tostring(tabber) --	return frame:expandTemplate{title = "BossSong", args = private.processCsv(args["x"])} end

function public.WorkshopWorldTitle(frame) local args = frame.args local x_params = private.processCsv(args[1]) return x_params[1] end

function public.WorkshopWorld(frame) local args = frame:getParent.args local x_params = private.processCsv(args["x"]) local x_call = frame:expandTemplate{title = "WorkshopBossSong", args = x_params} if args[1] ~= nil then local world = args["world"] local tabber = mw.html.create("div") tabber:addClass("tabberex") if world == nil then world = "?" end for k, v in ipairs(args) do			local template_params = private.processCsv(args[k]) local template_call = frame:expandTemplate{title = "TutorialSong", args = template_params} tabber:tag("div") :addClass("tabberex-tab") :attr("data-tab-header", world .. "-" .. k) :wikitext("\n" .. template_call .. "\n") :done end if args["x"] ~= nil then local x_header = world .. "-X" local x_icon = args["x_icon"] if x_icon == nil then x_icon = x_header .. " Icon.png" end local icon_title = mw.title.new("File:" .. x_icon) if icon_title["fileExists"] then x_header = "" .. x_header end tabber:tag("div") :addClass("tabberex-tab") :addClass("tabberex-tab-default") :tag("span") :addClass("tabberex-tab-header") :wikitext(x_header) :done :wikitext("\n" .. x_call .. "\n") :allDone end return tostring(tabber) end return tostring(x_call) end

function public.WorkshopWorldMechanics(frame) local args = frame.args local mechanics = private.processCsv(args[1]) local beat_intervals = {} local other_mechanics = {} for _, mechanic in ipairs(mechanics) do		local m = mechanic:sub(1, 1) if m == "b" then table.insert(beat_intervals, mechanic:sub(2,-1)) else local mechanic_description = " are present" if m == "m" then mechanic_description = "Midspins" .. mechanic_description elseif m == "c" then mechanic_description = "Checkpoints" .. mechanic_description .. " (" .. mechanic:sub(2, -1) .. ")" elseif m == "s" then m2 = mechanic:sub(2, 2) if m2 == "w" then mechanic_description = "Swirls" .. mechanic_description elseif m2 == "1" then mechanic_description = "Snails" .. mechanic_description elseif m2 == "2" then mechanic_description = "Double Snails" .. mechanic_description else mechanic_description = "Snails and Double Snails" .. mechanic_description end elseif m == "r" then m2 = mechanic:sub(2, 2) if m2 == "1" then mechanic_description = "Rabbits" .. mechanic_description elseif m2 == "2" then mechanic_description = "Double Rabbits" .. mechanic_description else mechanic_description = "Rabbits and Double Rabbits" .. mechanic_description end end mechanic_description = mechanic_description .. "."			table.insert(other_mechanics, mechanic_description) end end

local interval_line = "Beat Intervals: " for i, interval in ipairs(beat_intervals) do interval_line = interval_line .. interval if i == #beat_intervals then interval_line = interval_line .. "."		else interval_line = interval_line .. ", "		end end

--	local retval = mw.html.create("ul")	retval		:tag("li")			:wikitext(interval_line)		:done	for _, m in ipairs(other_mechanics) do		retval			:tag("li")				:wikitext(m)			:done	end	retval:allDone	return tostring(retval)	-- local retval = "* " .. interval_line for _, m in ipairs(other_mechanics) do retval = retval .. "\n* " .. m	end return retval end return public