From 140b7f3fd2fbc6fb07121dacd60a5bee1c5f5d41 Mon Sep 17 00:00:00 2001 From: garret Date: Wed, 22 Dec 2021 20:12:24 +0000 Subject: new script --- macros/garret.order-layers.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 macros/garret.order-layers.lua (limited to 'macros') diff --git a/macros/garret.order-layers.lua b/macros/garret.order-layers.lua new file mode 100644 index 0000000..62fec03 --- /dev/null +++ b/macros/garret.order-layers.lua @@ -0,0 +1,33 @@ +script_name = "Order layers" +script_description = "puts each selected line on its own layer so they don't clash" +script_author = "garret" +script_version = "1.0.0" + +local haveDepCtrl, DependencyControl, depctrl = pcall(require, "l0.DependencyControl") +if haveDepCtrl then + depctrl = DependencyControl { + --feed="TODO", + } +end + +local function main(sub, sel) + local i = 0 + local last_start, last_end + for si,li in ipairs(sel) do + line = sub[li] + if line.start_time == last_start or line.end_time == last_end or si == 1 then + line.layer = i + i = i + 1 + end + last_start = line.start_time + last_end = line.end_time + sub[li] = line + end + aegisub.set_undo_point(script_name) +end + +if haveDepCtrl then + depctrl:registerMacro(main) +else + aegisub.register_macro(script_name, script_description, main) +end -- cgit v1.2.3-70-g09d2