Module:Sandbox/SageVarq

From Mizuumi Wiki
Jump to navigation Jump to search

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

local p = {}

local currentFrame = 0
local wikitext = ""

function p.drawFrameDataV1(frame)
	-- Startup is the first active frame. Sets to true if empty, otherwise it's false.
	local startupIsFirstActive
	if frame.args['startupIsFirstActive'] == nil or frame.args['startupIsFirstActive'] == true or frame.args['startupIsFirstActive'] == yes then
		startupIsFirstActive = true
	else
		startupIsFirstActive = false
	end
	-- Startup of move, substract 1 if startupIsFirstActive
	local startup = frame.args['startup']
	if startupIsFirstActive and tonumber(startup) > 0 then
		startup = tonumber(startup) - 1
	end
	-- Active of move
	local active = frame.args['active']
	-- Recovery of move
	local recovery = frame.args['recovery']
	-- String to return
	local wikitext = ""
	local currentFrame = 0
	
	for i=1, tonumber(startup) do
		currentFrame = currentFrame + 1
		wikitext = wikitext .. addFrameSeparator(currentFrame)
		wikitext = wikitext .. "<div class=\"frame-data-startup\"></div>"
	end
	
	for i=1, tonumber(active) do
		currentFrame = currentFrame + 1
		wikitext = wikitext .. addFrameSeparator(currentFrame)
		wikitext = wikitext .. "<div class=\"frame-data-active\"></div>"
	end
	
	for i=1, tonumber(recovery) do
		currentFrame = currentFrame + 1
		wikitext = wikitext .. addFrameSeparator(currentFrame)
		wikitext = wikitext .. "<div class=\"frame-data-recovery\"></div>"
	end
	
	return wikitext
end

function p.drawFrameDataV2(frame)
	-- Startup is the first active frame. Sets to true if empty, otherwise it's false.
	local startupIsFirstActive
	if frame.args['startupIsFirstActive'] == nil or frame.args['startupIsFirstActive'] == true or frame.args['startupIsFirstActive'] == yes then
		startupIsFirstActive = true
	else
		startupIsFirstActive = false
	end
	-- Startup of move, substract 1 if startupIsFirstActive
	local startup = frame.args['startup']
	if tonumber(startup) ~= nil then
		if startupIsFirstActive and tonumber(startup) > 0 then
			startup = tonumber(startup) - 1
		end
	end
	-- Active of move
	local active = frame.args['active']
	-- Inactive of move
	local inactive = frame.args['inactive']
	-- Active2 of move
	local active2 = frame.args['active2']
	-- Inactive of move
	local inactive2 = frame.args['inactive2']
	-- Active3 of move
	local active3 = frame.args['active3']
	-- Inactive of move
	local inactive3 = frame.args['inactive3']
	-- Active4 of move
	local active4 = frame.args['active4']
	-- Inactive of move
	local inactive4 = frame.args['inactive4']
	-- Active5 of move
	local active5 = frame.args['active5']
	-- Recovery of move
	local recovery = frame.args['recovery']
	-- String to return
	local wikitext = ""
	local currentFrame = 0
	
	if tonumber(startup) ~= nil then
		for i=1, tonumber(startup) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-startup\"></div>"
		end
	end
	
	if tonumber(active) ~= nil then
		for i=1, tonumber(active) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-active\"></div>"
		end
	end
	
	if tonumber(inactive) ~= nil then
		for i=1, tonumber(inactive) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-inactive\"></div>"
		end
	end
	
	if tonumber(active2) ~= nil then
		for i=1, tonumber(active2) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-active\"></div>"
		end
	end
	
	if tonumber(inactive2) ~= nil then
		for i=1, tonumber(inactive2) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-inactive\"></div>"
		end
	end
	
	if tonumber(active3) ~= nil then
		for i=1, tonumber(active3) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-active\"></div>"
		end
	end
	
	if tonumber(inactive3) ~= nil then
		for i=1, tonumber(inactive3) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-inactive\"></div>"
		end
	end
	
	if tonumber(active4) ~= nil then
		for i=1, tonumber(active4) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-active\"></div>"
		end
	end
	
	if tonumber(inactive4) ~= nil then
		for i=1, tonumber(inactive4) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-inactive\"></div>"
		end
	end
	
	if tonumber(active5) ~= nil then
		for i=1, tonumber(active5) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-active\"></div>"
		end
	end
	
	if tonumber(recovery) ~= nil then
		for i=1, tonumber(recovery) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-recovery\"></div>"
		end
	end
	
	return wikitext
end

function p.drawFrameDataV3(frame)
	-- Startup is the first active frame. Sets to true if empty, "true", or "yes". Otherwise it's false.
	local startupIsFirstActive
	if frame.args['startupIsFirstActive'] == nil or frame.args['startupIsFirstActive'] == true or frame.args['startupIsFirstActive'] == yes then
		startupIsFirstActive = true
	else
		startupIsFirstActive = false
	end
	
	-- Startup of move, substract 1 if startupIsFirstActive
	local startup = frame.args['startup']
	if tonumber(startup) ~= nil then
		if startupIsFirstActive and tonumber(startup) > 0 then
			startup = tonumber(startup) - 1
		end
	end
	
	-- Active of move
	local active = frame.args['active']
	-- Inactive of move
	local inactive = frame.args['inactive']
	-- Recovery of move
	local recovery = frame.args['recovery']
	-- String to return
	
	drawFrame(startup,  "startup")
	drawFrame(active,   "active")
	drawFrame(inactive, "inactive")
	
	local index = 2
	while tonumber(frame.args['active' .. index]) ~= nil or tonumber(frame.args['inactive' .. index]) ~= nil do
		drawFrame(frame.args['active' .. index], "active")
		drawFrame(frame.args['inactive' .. index], "inactive")
		index = index + 1
	end
	
	drawFrame(recovery, "recovery")
	
	return wikitext
end

function drawFrame(frames, frameType)	
	if tonumber(frames) ~= nil then
		for i=1, tonumber(frames) do
			currentFrame = currentFrame + 1
			wikitext = wikitext .. addFrameSeparator(currentFrame)
			wikitext = wikitext .. "<div class=\"frame-data-" .. frameType .. "\"></div>"
		end
	end
end

function addFrameSeparator(frame)
	local retString = ""
	if frame % 5 == 1 then
		retString = "<div class=\"frame-data-separator\"></div>"
	end
	return retString
end

return p