A-B: clean up code
local functions split a thing off into a function sane function name hmm lot of functions this time also local variables and addressing luacheck warnings
This commit is contained in:
parent
dcdbacb94e
commit
aeb5c6182f
|
@ -11,7 +11,7 @@ if haveDepCtrl then
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function switch_number(i)
|
local function switch_indicator(i)
|
||||||
if i == "a" then
|
if i == "a" then
|
||||||
return "b"
|
return "b"
|
||||||
elseif i == "b" then
|
elseif i == "b" then
|
||||||
|
@ -19,22 +19,34 @@ function switch_number(i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function main(sub, sel)
|
local function strip_tags(text)
|
||||||
local i = "a"
|
return text:gsub("{[^}]-}","")
|
||||||
for si,li in ipairs(sel) do
|
|
||||||
line = sub[li]
|
|
||||||
if line.actor == "" then
|
|
||||||
indicator = i
|
|
||||||
else
|
|
||||||
indicator = line.actor.." "..i
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_indicator(letter, actor)
|
||||||
|
local indicator
|
||||||
|
if actor == "" then
|
||||||
|
indicator = letter
|
||||||
|
else
|
||||||
|
indicator = actor.." "..letter
|
||||||
|
end
|
||||||
|
return indicator
|
||||||
|
end
|
||||||
|
|
||||||
|
local function main(sub, sel)
|
||||||
|
local i = "a"
|
||||||
|
for _,li in ipairs(sel) do
|
||||||
|
local line = sub[li]
|
||||||
|
local indicator = get_indicator(i, line.actor)
|
||||||
|
|
||||||
if line.text == "" then
|
if line.text == "" then
|
||||||
line.text = indicator
|
line.text = indicator
|
||||||
elseif line.text:gsub("{[^}]-}","") == "" then
|
elseif strip_tags(line.text) == "" then
|
||||||
line.text = line.text .. indicator -- apply tags
|
line.text = line.text .. indicator -- apply tags
|
||||||
end
|
end
|
||||||
|
|
||||||
sub[li] = line
|
sub[li] = line
|
||||||
i = switch_number(i)
|
i = switch_indicator(i)
|
||||||
end
|
end
|
||||||
aegisub.set_undo_point(script_name)
|
aegisub.set_undo_point(script_name)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue