Module:FrameChart

From Mizuumi Wiki
Jump to navigation Jump to search

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

--taken from dustloop wiki
local p = {}

local currentFrame = 0
local wikitext = ""

function p.drawFrameData(frame)
  -- Startup is the first active frame. Sets to true if empty. Otherwise it's false.
  local startupIsFirstActive = true
  --[[MBTL uses this system
  if frame.args['startupIsFirstActive'] == nil 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']
  -- Special Recovery of move
  local specialRecovery = frame.args['specialRecovery']
  -- How many frames into active frames the inactive period occurs
  local offset = frame.args['offset']
  -- String to return
  
  drawFrame(startup,  "startup")
  if offset ~= nil then
    drawFrame(offset,   "active")
    drawFrame(inactive, "inactive")
    drawFrame(active-offset,   "active")
  else
    drawFrame(active,   "active")
  end
  
  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")
  drawFrame(specialRecovery, "specialRecovery")
  
  return wikitext
end

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

return p