Aegisub
Aegisub copied to clipboard
apply karaoke template error
error code:
Runtime error in template code: Expected 1 arguments, got 2 Code producing error: ci = { 0,0 }; cn = _G.unicode.len(orgline.text_stripped:gsub(" ",""))
Add a new pair of parentheses to fix the problem.
Like this: ci = { 0,0 }; cn = _G.unicode.len((orgline.text_stripped:gsub(" ","")))
For an explanation, this is a result of how between Lua 5.1 and 5.2 (with LuaJIT compat mode), if I remember correctly, string.gsub
was changed to return multiple values and the default behavior of Lua in such a case is to pass all values as a result to a single-argument function call into the function as arguments. The extra pair of parentheses makes Lua strip all but the first value so that _G.unicode.len
only receives one argument.
Another option: work in a templater that actually counts character indices for you so that this code that gets copy-pasted everywhere isn't actually necessary.