Add tenv.maxj (upper loop bound)

Originally committed to SVN as r1564.
This commit is contained in:
Niels Martin Hansen 2007-09-19 21:58:25 +00:00
parent 86fad7d3b2
commit 51616fea0b

View file

@ -444,6 +444,7 @@ function apply_line(meta, styles, subs, line, templates, tenv)
aegisub.debug.out(5, "Running line templates\n") aegisub.debug.out(5, "Running line templates\n")
for t in matching_templates(templates.line, line, tenv) do for t in matching_templates(templates.line, line, tenv) do
tenv.j = 0 tenv.j = 0
tenv.maxj = t.loops
while tenv.j < t.loops do while tenv.j < t.loops do
tenv.j = tenv.j + 1 tenv.j = tenv.j + 1
if t.code then if t.code then
@ -519,6 +520,7 @@ function run_code_template(template, tenv)
else else
local pcall = pcall local pcall = pcall
setfenv(f, tenv) setfenv(f, tenv)
tenv.maxj = template.loops
for j = 1, template.loops do for j = 1, template.loops do
tenv.j = j tenv.j = j
local res, err = pcall(f) local res, err = pcall(f)
@ -676,6 +678,7 @@ function apply_one_syllable_template(syl, line, template, tenv, varctx, subs, sk
run_code_template(t, tenv) run_code_template(t, tenv)
else else
aegisub.debug.out(5, "Running %d effect loops\n", t.loops) aegisub.debug.out(5, "Running %d effect loops\n", t.loops)
tenv.maxj = t.loops
for j = 1, t.loops do for j = 1, t.loops do
tenv.j = j tenv.j = j
local newline = table.copy(line) local newline = table.copy(line)