Multi-Template tutorial
From Aegisub Wiki
|
This tutorial will teach you how to use multi-template.lua to create more effects similar to those possible with line-per-syllable.lua easier, and even more advanced effects.
Prerequisites:
- Some timed karaoke
- Experience with line-per-syllable.lua
[edit] What's wrong with line-per-syllable
Simply put: It's too simple.
It only allows one line per syllable, and you can't control the timing of that line.
Also, because the effects might end up rather long, it's not really convenient entering them into that tiny textbox offered in the configuration window. In fact, many effects are better suited for splitting into multiple lines.
The solution is to let the effect be "part of" the subtitles.
[edit] Part one: Translating from line-per-syllable
First, let's try "translating" an effect from the line-per-syllable script.
- Load your karaoke timed subtitles and multi-template.lua. Close the Automation Manager.
Create a new line at the beginning of the subtitle file. Mark it as a comment, and set the actor field to "template".
Set the text of the new line to this:
{\an5\shad0\pos($x,40)\t($start,$end,\fry360)}The timing of the new line doesn't matter, but the style must match that of the lines you want the effect to apply to.
- Now export the file with the Template-based effects filter enabled. You should get the same effect as the first line-per-syllable example.
That's all there is to the basic usage of multi-template. In its basic form it works almost the same, except that you write the effects directly in the subtitle lines.
The important points of this lesson:
- multi-template is based upon special template lines.
- A template line is created by setting these properties on a line:
- Make it a comment, and
- Set the actor field to template.
- Use the same kinds of variables and calculations as in line-per-syllable.
- multi-template templates "lock" onto styles, by setting their style field. You can not have one template line that applies to multiple styles.
[edit] Part two: Advanced effects through multiple templates
Now let's move on to creating something not possible with line-per-syllable, an effect that requires multiple lines per syllable.
This is in fact very easy, just make multiple template lines per style:
- Continuing from above, create a copy of the template line. (Right click on it and select "Duplicate".)
Change the text of the new line to:
{\an5\1c&HFFFFFF&\shad0\bord0\1a&HFF&\pos($x,40)\t($start,$start,\1a&H80&)\t($start,$end,\fscx300\fscy50\1a&HFF&)}What this does: Show a white copy of the syllable when it starts and make it stretch and fade out during the syllables duration.

- Try exporting again, and check the effect looks right.
Let's build a little more upon this effect, and maybe fix a little ugliness.
The "white flash" part is fine for now, so we'll leave that alone, but create another copy of the original template line, so there are two identical lines. Now change the layer of each of those two lines, the first to 1 and the second to 2. Also change the layer of the "white flash" line to 3, so it won't appear below the other effects.
Change the text of the layer 1 template to this:
{\an5\shad0\1a&HFF&\pos($x,40)\t($start,$end,\fry360)}Change the text of the layer 2 template to this:
{\an5\shad0\bord0\pos($x,40)\t($start,$end,\fry-360)}Notice that the two lines rotate in different directions. The lower one will only be border, and the upper one will only be fill.
When border and fill are split like this you avoid an ugly effect where the border of some syllables will overlap the fill of neighboring syllables, because the border of all syllables are below the fill of all other syllables.
- Once again, export the subtitles, applying the effect, and check it looks right.
This part hopefully showed how easily you can make far more advanced effects with little to no trouble, but there's still more to it! That will be covered in the next part, for now a summary:
- You can have multiple template lines for each style, and they will all be used.
- Use the layer field to put parts of the effect into different layers, to avoid unwanted overlaps.
[edit] Part three: Conditional effects
Now, how about having some parts of an effect that isn't used for every syllable? Maybe have two different effects for different syllables? Well, it's no real problem, there's a very easy way to deal with it.
%if A.syl.inline_fx ~= "flash" then return false%{effect here}
incomplete
[edit] Part four: Changing line timing
%A.newline.end_time = A.newline.start_time; A.newline.start_time = A.newline.start_time - 50; return ""%{\move($x,-40,$x,40)}
Where I put this string???


