mirror of https://github.com/odrling/Aegisub
Runtime errors in auto3 scripts no longer kill the program but are reported properly instead.
Apparently Lua 5.1 has changed the semantics of table.insert so it's incompatible with the way used in all Auto3 demo scripts etc. Now it's overridden in utils.auto3 and all instances of it in sample scripts etc. replaced with code having the expected behaviour. Originally committed to SVN as r926.
This commit is contained in:
parent
caea5872b4
commit
6dcb5ff4a8
|
@ -962,7 +962,14 @@ continue_invalid_option:
|
|||
|
||||
sink->SetTask(_T("Running script for processing"));
|
||||
sink->SetProgress(100.0f/3);
|
||||
lua_call(L, 4, 1);
|
||||
int ret = lua_pcall(L, 4, 1, 0);
|
||||
if (ret) {
|
||||
wxString emsg(lua_tostring(L, -1), wxConvUTF8);
|
||||
emsg.Prepend(_T("The Automation 3 script produced an error:\n"));
|
||||
emsg.Append(_T("\nThe subtitles have not been altered."));
|
||||
lua_pushstring(L, emsg.mb_str(wxConvUTF8));
|
||||
throw ret;
|
||||
}
|
||||
sink->SetProgress(200.0f/3);
|
||||
sink->SetTask(_T("Reading back data from script"));
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ function do_syllable(meta, styles, config, line, syl)
|
|||
-- The result from this function can just be modified, and the line in the result table changes along (since it's just a reference)
|
||||
function result.add()
|
||||
local l = copy_line(line)
|
||||
table.insert(result, l)
|
||||
result.n = result.n + 1
|
||||
result[result.n] = l
|
||||
return l
|
||||
end
|
||||
-- Place the main text
|
||||
|
|
|
@ -16,7 +16,8 @@ function process_lines(meta, styles, lines, config)
|
|||
aegisub.report_progress(i/lines.n*100)
|
||||
-- Only process dialogue lines
|
||||
if lines[i].kind ~= "dialogue" then
|
||||
table.insert(output, lines[i])
|
||||
output.n = output.n + 1
|
||||
output[output.n] = lines[i]
|
||||
else
|
||||
-- This is just for making the code a bit easier to read
|
||||
local line = lines[i]
|
||||
|
@ -40,7 +41,8 @@ function process_lines(meta, styles, lines, config)
|
|||
-- Replace the text of the copy of the line with this syllable, moving around
|
||||
syllin.text = string.format("{\\an4\\move(%d,%d,%d,%d,%d,%d)\\kf%d\\kf%d}%s", curx, cury, curx, cury-exty, tstart, tend, tstart/10, syl.duration, syl.text)
|
||||
-- Add the line to the output
|
||||
table.insert(output, syllin)
|
||||
output.n = output.n + 1
|
||||
output[output.n] = syllin
|
||||
-- And prepare for next iteration
|
||||
curx = curx + extx
|
||||
tstart = tend
|
||||
|
|
|
@ -24,7 +24,8 @@ function process_lines(meta, styles, lines, config)
|
|||
aegisub.report_progress(i/lines.n*100)
|
||||
-- First check if the line is even a dialogue line. If it's not, no need to process it.
|
||||
if lines[i].kind ~= "dialogue" then
|
||||
table.insert(output, lines[i])
|
||||
output.n = output.n + 1
|
||||
output[output.n] = lines[i]
|
||||
else
|
||||
-- This is a dialogue line, so process is
|
||||
-- Make a nicer name for the line we're processing
|
||||
|
@ -55,7 +56,8 @@ function process_lines(meta, styles, lines, config)
|
|||
|
||||
-- The entire line has been calculated
|
||||
-- Add it to the output
|
||||
table.insert(output, newline)
|
||||
output.n = output.n + 1
|
||||
output[output.n] = newline
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ function process_lines(meta, styles, lines, config)
|
|||
dokanji(lin, output, styles["op kanji"])
|
||||
else
|
||||
-- Unknown lines are copied verbatim
|
||||
table.insert(output, lin)
|
||||
output.n = output.n + 1
|
||||
output[output.n] = lin
|
||||
end
|
||||
end
|
||||
return output
|
||||
|
@ -110,7 +111,8 @@ function doromaji(lin, output, sty, linetop)
|
|||
enterlin.start_time = lin.start_time - 40
|
||||
enterlin.end_time = lin.start_time
|
||||
enterlin.text = string.format("{\\move(%d,%d,%d,%d)\\fr%d\\t(\\fr0)\\an7}%s", startx, starty, shakex, shakey, -math.deg(enterangle), syl.text)
|
||||
table.insert(output, enterlin)
|
||||
output.n = output.n + 1
|
||||
output[output.n] = enterlin
|
||||
-- main highlight effect
|
||||
local newlin = copy_line(lin)
|
||||
local hilistart, hilimid, hiliend = syl.start_time*10, (syl.start_time+syl.duration/2)*10, (syl.start_time+syl.duration)*10
|
||||
|
@ -127,8 +129,9 @@ function doromaji(lin, output, sty, linetop)
|
|||
bord.layer = 0
|
||||
bord.text = "{" .. bord.text
|
||||
newlin.text = "{\\bord0" .. newlin.text
|
||||
table.insert(output, bord)
|
||||
table.insert(output, newlin)
|
||||
output.n = output.n + 2
|
||||
output[output.n-1] = bord
|
||||
output[output.n] = newlin
|
||||
-- leave effect
|
||||
-- cut the line over in two, lower half "drops down", upper just fades away
|
||||
local tophalf = copy_line(lin)
|
||||
|
@ -138,8 +141,9 @@ function doromaji(lin, output, sty, linetop)
|
|||
local bottomhalf = copy_line(tophalf)
|
||||
tophalf.text = string.format("{\\t(0,200,\\1c&H000080&)\\clip(0,0,640,%d)%s", linetop+syl.height/2, tophalf.text)
|
||||
bottomhalf.text = string.format("{\\org(%d,%d)\\clip(0,%d,640,480)\\t(0,200,\\1c&H000080&)\\t(200,1000,1.2,\\frx90\\clip(0,%d,640,480)%s", 320, linetop+syl.height, linetop+syl.height/2, linetop+syl.height, bottomhalf.text)
|
||||
table.insert(output, tophalf)
|
||||
table.insert(output, bottomhalf)
|
||||
output.n = output.n + 2
|
||||
output[output.n-1] = tophalf
|
||||
output[output.n] = bottomhalf
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -190,7 +194,8 @@ function dokanji(lin, output, sty)
|
|||
end
|
||||
newlin.text = string.format("{\\fn%s\\an7\\fr-90\\move(%d,%d,%d,%d)\\1a&H%2x&\\3a&H%2x&\\t(\\1a&H%2x&\\3a&H%2x&)}%s", fontname, 620, top, 620, top-syl.height, startalpha, startalpha, targetalpha, targetalpha, syls[i+j].text)
|
||||
top = top + syls[i+j].height
|
||||
table.insert(output, newlin)
|
||||
output.n = output.n + 1
|
||||
output[output.n] = newlin
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ karaskel.engage_positioning = true
|
|||
-- The arguments here mean the same as in karaskel.lua, and all tables have the same members
|
||||
-- The return value is different now, though.
|
||||
-- It is required to be in the same format as the do_line function:
|
||||
-- A table with an "n" key, and keys 0..n-1 with line structures.
|
||||
-- A table with an "n" key, and keys 1..n with line structures.
|
||||
function karaskel.do_syllable(meta, styles, config, line, syl)
|
||||
karaskel.trace("default_do_syllable")
|
||||
return {n=0}
|
||||
|
@ -60,11 +60,15 @@ function karaskel.do_line(meta, styles, config, line)
|
|||
for i = 0, line.karaoke.n-1 do
|
||||
karaskel.trace("adv_do_line:2:"..i)
|
||||
local out = do_syllable(meta, styles, config, line, line.karaoke[i])
|
||||
karaskel.trace("adv_do_line:produced " .. out.n)
|
||||
for j = 1, out.n do
|
||||
table.insert(result, out[j])
|
||||
karaskel.trace("adv_do_line:produced:" .. out[j].kind)
|
||||
result.n = result.n + 1
|
||||
result[result.n] = out[j]
|
||||
end
|
||||
karaskel.trace("adv_do_line:3:"..result.n)
|
||||
end
|
||||
karaskel.trace("adv_do_line:3")
|
||||
karaskel.trace("adv_do_line:4")
|
||||
return result
|
||||
end
|
||||
do_line = karaskel.do_line
|
||||
|
|
|
@ -51,7 +51,7 @@ karaskel = {
|
|||
-- Set this to the name of the style used for out-of-line effect specifications, if any (read manual on this!)
|
||||
ool_fx_style = false,
|
||||
-- Show tracing messages?
|
||||
engage_trace = false
|
||||
engage_trace = true
|
||||
}
|
||||
|
||||
function karaskel.warning(s)
|
||||
|
@ -300,10 +300,11 @@ function karaskel.process_lines(meta, styles, lines, config)
|
|||
-- Get replacement lines
|
||||
lines[i].ool_fx = ool_fx
|
||||
repl = do_line(meta, styles, config, lines[i])
|
||||
karaskel.trace("skel_process_lines:4:"..i)
|
||||
karaskel.trace("skel_process_lines:4:"..i..":"..repl.n)
|
||||
-- Append to result table
|
||||
for j = 1, repl.n do
|
||||
table.insert(result, repl[j])
|
||||
result.n = result.n + 1
|
||||
result[result.n] = repl[j]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -177,3 +177,12 @@ function xor(a, b)
|
|||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Lua 5.1 breaks the table.insert function, here's a "fix"
|
||||
table.org_insert = table.insert
|
||||
function table.insert(tab, val)
|
||||
aegisub.output_debug("Warning: this script uses the table.insert function which has changed behaviour in Lua 5.1. This might cause problems. Please update the script so it does not use this function, and instead replace it with code equivalent to the intended behaviour.")
|
||||
tab.n = tab.n + 1
|
||||
tab[tab.n] = val
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue