diff options
author | garret <garret@airmail.cc> | 2024-02-25 23:01:13 +0000 |
---|---|---|
committer | garret <garret@airmail.cc> | 2024-02-25 23:08:47 +0000 |
commit | 67d261ab378fa9166ee6e0c31b7cb4e32a019925 (patch) | |
tree | 1fbd2153481e675f283f731c1da59d584513f2c9 /sylsplitter.lua | |
parent | 5edf42a777b02ab939ab751a7d3e7eb0a7efde70 (diff) | |
download | aegisub-scripts-67d261ab378fa9166ee6e0c31b7cb4e32a019925.tar.gz aegisub-scripts-67d261ab378fa9166ee6e0c31b7cb4e32a019925.tar.bz2 aegisub-scripts-67d261ab378fa9166ee6e0c31b7cb4e32a019925.zip |
get rid of dependencycontrol bullshit
there is no sense in me keeping it around when all it does is
add faff to writing the script
add useless noise to the filenames/paths
and enforces its opinions upon me which i dont agree with
and all for absolutely ZERO reason since i don't even have a feed in the
first place
if you want to take my scripts and package them into a dependencycontrol
feed, you are more than welcome to do so, provided you comply with the
terms of the licence. but your life is going to be a little bit harder
i'm afraid, sorry about that.
i will keep all the script_namespace, depctrl registration and such
around for the time being (removing it is >effort)
Diffstat (limited to 'sylsplitter.lua')
-rw-r--r-- | sylsplitter.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sylsplitter.lua b/sylsplitter.lua new file mode 100644 index 0000000..615f730 --- /dev/null +++ b/sylsplitter.lua @@ -0,0 +1,43 @@ +script_name = "Syllable Splitter" +script_description = "splits romaji into syls of their original kana. for the lazy k-timer." +script_author = "garret" +script_version = "1.0.1" +script_namespace = "garret.sylsplitter" + +local haveDepCtrl, DependencyControl, depctrl = pcall(require, "l0.DependencyControl") +local re +if haveDepCtrl then + depctrl = DependencyControl({ + --feed="TODO", + { "aegisub.re" }, + }) + re = depctrl:requireModules() +else + re = require("aegisub.re") +end + +local function round(num, numDecimalPlaces) -- https://lua-users.org/wiki/SimpleRound + local mult = 10^(numDecimalPlaces or 0) + return math.floor(num * mult + 0.5) / mult +end + +local function add_tag(syl) + -- default syl duration = (line duration / line chars) * syl chars + local syl_dur = round(((line.end_time - line.start_time) / 10) / #line.text) + return "{\\k"..syl_dur * #syl .. "}" ..syl +end + +local function main(sub,sel) + local kana = re.compile("a|i|u|e|o|ya|yu|yo|ka|ki|ku|ke|ko|kya|kyu|kyo|sa|shi|su|se|so|sha|shu|sho|ta|chi|tsu|te|to|cha|chu|cho|na|ni|nu|ne|no|nya|nyu|nyo|ha|hi|fu|he|ho|hya|hyu|hyo|ma|mi|mu|me|mo|mya|myu|myo|ra|ri|ru|re|ro|rya|ryu|ryo|ga|gi|gu|ge|go|gya|gyu|gyo|za|ji|zu|ze|zo|ja|ju|jo|da|ji|zu|de|do|ja|ju|jo|ba|bi|bu|be|bo|bya|byu|byo|pa|pi|pu|pe|po|pya|pyu|pyo|wa|wo|n|-|[a-z]") -- all kana + all letters (for small っ) (probably dont need _all_ letters but whatever) + for i = 1, #sel do + line = sub[sel[i]] -- yes global, i know(ish) what im doing + line.text = kana:sub(line.text, add_tag) + sub[sel[i]] = line + end +end + +if haveDepCtrl then + depctrl:registerMacro("Split Syllables", script_description, main) +else + aegisub.register_macro("Split Syllables", script_description, main) +end |