~ubuntu-branches/ubuntu/trusty/aegisub/trusty

« back to all changes in this revision

Viewing changes to automation/demos/auto3/8-skeleton.lua

  • Committer: Package Import Robot
  • Author(s): Sebastian Reichel
  • Date: 2012-03-16 22:58:00 UTC
  • Revision ID: package-import@ubuntu.com-20120316225800-yfb8h9e5n04rk46a
Tags: upstream-2.1.9
ImportĀ upstreamĀ versionĀ 2.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-- Aegisub Automation demonstration script
 
2
-- Original written by Niels Martin Hansen
 
3
-- Given into the public domain
 
4
 
 
5
name = "Karaoke skeleton demo"
 
6
description = "This script demonstrates the use of the karaskel.lua include file, to avoid writing almost identical code for every karaoke effect script."
 
7
version, kind, configuration = 3, 'basic_ass', {}
 
8
 
 
9
-- Include the "magic" karaskel.lua file. It also includes utils.lua for you.
 
10
-- karaskel.lua defines the process_lines function, so you'll usually not have to write that yourself
 
11
include("karaskel.lua")
 
12
 
 
13
-- Instead, a do_syllable function is written. This is called by karaskel for every syllable, to get the text replacement for that syllable.
 
14
function do_syllable(meta, styles, config, line, syl)
 
15
        -- First check if it's the first syllable on the line; if it is don't bother doing anything special
 
16
        if syl.i == 0 then
 
17
                -- Remember you have to return the text of the syllable as well as any formatting tags you want
 
18
                return syl.text
 
19
        else
 
20
                -- For other syllables, apply a little effect
 
21
                return string.format("{\\r\\k%d\\t(%d,%d,\\1c&H%s&)}%s", syl.duration, syl.start_time, syl.end_time, line.styleref.color2, syl.text)
 
22
        end
 
23
end
 
24
 
 
25
-- Exercise for the reader: Rewrite this script in "classic style", ie. the same way as demo 6.
 
26
-- See how few lines you can get it down to, while still producing the same effect.