diff options
author | garret <garret@airmail.cc> | 2021-07-10 17:06:04 +0100 |
---|---|---|
committer | garret <garret@airmail.cc> | 2021-07-10 17:06:04 +0100 |
commit | 2d140d49e5c564b6839fe93c88b7978dd96b8374 (patch) | |
tree | 6abad58bbb8f7d99236a1da5b9eafd828e163f76 /a-b.lua | |
parent | 659ed31a8c771d2855774cd0e3bb33f8f8d6a4f7 (diff) | |
download | aegisub-scripts-2d140d49e5c564b6839fe93c88b7978dd96b8374.tar.gz aegisub-scripts-2d140d49e5c564b6839fe93c88b7978dd96b8374.tar.bz2 aegisub-scripts-2d140d49e5c564b6839fe93c88b7978dd96b8374.zip |
improve a-b
Diffstat (limited to 'a-b.lua')
-rw-r--r-- | a-b.lua | 33 |
1 files changed, 23 insertions, 10 deletions
@@ -1,21 +1,34 @@ script_name = "A-B" -script_description = "makes checking pre-timing possible.\nCAUTION: Overwrites every selected line!" +script_description = "makes checking pre-timing possible." script_author = "garret" -script_version = "2021-04-03" +script_version = "2021-07-10" + +function switch_number(i) + if i == "a" then + return "b" + elseif i == "b" then + return "a" + end +end + function main(sub, sel) - local i = 0 + local i = "a" for si,li in ipairs(sel) do line = sub[li] - if i == 0 then - line.text = line.actor.." a" - i = 1 - elseif i == 1 then - line.text = line.actor.." b" - i = 0 + if line.actor == "" then + indicator = i + else + indicator = line.actor.." "..i + end + if line.text == "" then + line.text = indicator + elseif line.text:gsub("{[^}]-}","") == "" then + line.text = indicator.." "..line.text end sub[li] = line + i = switch_number(i) end aegisub.set_undo_point(script_name) - return sel end + aegisub.register_macro(script_name, script_description, main) |