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 | --[[ | ||
- 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 | |||
- 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 | ||
--[[ | --[[ | ||
- 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 | |||
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 | |||
- 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 | ||
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 | ||