Module:Step vis: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
Line 18: Line 18:
local previous_step_size = 0
local previous_step_size = 0
-- For each step size of k, print a single border, followed by k-1 no-border symbols
--[[
-- If this is the first step, print the left border instead
- For each step size of k, print a single border, followed by k-1 no-border symbols
-- If the step size is 0, print a double border only; if this happens, the next step should start with a border character
- If this is the first step, print the left border instead
-- If this is the last step, add a right border after the entire sequence
- If the step size is 0, print a double border only; if this happens, the next step should start with a border character
- If this is the last step, add a right border after the entire sequence
]]--
for i = 1, #step_pattern do
for i = 1, #step_pattern do
local current_step_vis = ""
local current_step_vis = ""
Line 35: Line 37:
if (previous_step_size == 0) then
if (previous_step_size == 0) then
--[[
--[[
- If the second-to-last and last step sizes are both 0, remove the double centre border at the end
- The beginning of a string is index 1 in the first argument of string.sub
- The beginning of a string is index 1 in the first argument of string.sub
- The end of the string is index -1 in the second argument of string.sub, and an ampersand version
- The end of the string is index -1 in the second argument of string.sub, and an ampersand version
  of a 4-digit code point is 8 characters long, so removing the last box-drawing character means
  of a 4-digit code point is 8 characters long, so removing the last box-drawing character means
  removing the last 8 characters representing it, between indices -1 and -9
  removing the last 8 characters representing it, between indices -1 and -9
- This removes the double centre border at the end if the second-to-last and last steps are both 0
]]--
]]--
step_visualization = string.sub(step_visualization, 1, -9)
step_visualization = string.sub(step_visualization, 1, -9)
Line 45: Line 47:
current_step_vis = double_border_right
current_step_vis = double_border_right
else
else
-- If the last step size is not 0
-- If the last step size is not 0, add a single border, then add the horizontal bar and right border
current_step_vis = (previous_step_size == 0 and "" or single_border) .. string.rep(no_border, current_step_size - 1) .. right_border
if previous_step_size ~= 0 then
current_step_vis = current_step_vis .. single_border
end
current_step_vis = current_step_vis .. string.rep(no_border, current_step_size - 1) .. right_border
end
end
else
else