AnimeSuki Forums

Register Forum Rules FAQ Members List Social Groups Search Today's Posts Mark Forums Read

Go Back   AnimeSuki Forum > Anime Related Topics > Fansub Groups

Notices

Reply
 
Thread Tools
Old 2007-07-23, 07:54   Link #481
OpeTh
Fansub PowA
 
 
Join Date: Jul 2007
Location: Cranfield - UK
Age: 29
I would like to put an effect code before numerous dialogue lines with a script in lua but I have some troubles.
Here is the code :
Code:
include("karaskel-adv.lua")

function do_line(meta, styles, config, line)

	local result = {n=0}

	local l = copy_line(line)
	l.layer = 2
	l.start_time = line.start_time - 25
	l.text = string.format("{\\an2\\fad(250,250)}%s", line.text)
	
	table.insert(result, l)
	
	return result
end
And here is the log of the error :
Code:
14:43:25: Script wrapper: Script produced an exception.
14:43:25: Message was: Lua runtime error: [string "user script"]:13: attempt to perform arithmetic on field `start_time' (a nil value)
14:43:25: Script wrapper: Output data are probably unchanged or corrupted.
I don't understand why there is a problem with the time value :?
But even if I erase the "- 25", there is still this error :
Code:
14:44:09: Script wrapper: Script produced an exception.
14:44:09: Message was: Lua runtime error: [string "user script"]:14: bad argument #2 to `format' (string expected, got nil)
14:44:09: Script wrapper: Output data are probably unchanged or corrupted.
I also don't understand why it occurs.
So if anyone could explain me what are my mistakes, it would be grate
__________________
Après la tempête, le calme éphémère...
OpeTh is offline   Reply With Quote
Old 2007-07-23, 16:02   Link #482
jfs
Aegisub dev
 
 
Join Date: Sep 2004
Location: Stockholm, Sweden
Age: 30
I can't imagine what's going wrong there. Maybe it's code rot, Automation 3 showing its age. (j/k) As far as I can tell it should work.
__________________

Aegisub developer [ Forum | Manual | Feature requests | Bug reports | IRC ]
Don't ask for: More VSFilter changes (I won't), karaoke effects, help in PM's
jfs is offline   Reply With Quote
Old 2007-08-05, 08:49   Link #483
OpeTh
Fansub PowA
 
 
Join Date: Jul 2007
Location: Cranfield - UK
Age: 29
I found why it didn't work ^^
I had to add just one 'if' condition to the script Oo :
Code:
include("karaskel-adv.lua")

function do_line(meta, styles, config, line)

	local result = {n=0}
	
	if line.kind == "dialogue" then
		local l = copy_line(line)
		l.layer = 2
		l.start_time = line.start_time - 25
		l.text = string.format("{\\an2\\fad(250,250)}%s", line.text)
		
		table.insert(result, l)
	end
	return result
end
It is a strange but simple solution
__________________
Après la tempête, le calme éphémère...
OpeTh is offline   Reply With Quote
Old 2007-08-05, 08:57   Link #484
edogawaconan
LOL?
*Fansubber
 
 
Join Date: Aug 2006
Location: Indonesia
Send a message via MSN to edogawaconan Send a message via Yahoo to edogawaconan
Quote:
I would like to put an effect code before numerous dialogue lines with a script in lua but I have some troubles.
why use lua?
edogawaconan is offline   Reply With Quote
Old 2007-08-05, 13:37   Link #485
Zanejin
Junior Member
*Fansubber
 
 
Join Date: Jun 2007
Quote:
Originally Posted by edogawaconan View Post
why use lua?
...rather than what? Lua is the core of simple karaoke generation in Aegisub. It's flexible and rather easy.
__________________
Zanejin is offline   Reply With Quote
Old 2007-08-05, 14:30   Link #486
OpeTh
Fansub PowA
 
 
Join Date: Jul 2007
Location: Cranfield - UK
Age: 29
Zanejin is right, if you have more than 100 lines to modify. It begins a little blooding to do it manually...
With a lua script, you're done in a maximum of 3 minutes

But, that's not the subject of my post :lol:
I would like to know if someone could tell me how to convert hexadecimal values (such as those used for the declaration of colors in ass) to digit values.
I know how to convert digit to hexadecimal values with this kind of code for example:
Code:
local a = 255
local l = copy_line(line)
l.text = string.format("{\\1a&H%02X&}%s", a, line.text)
table.insert(result, l)
So if someone could help me, I would appreciate a lot.

EDIT : After several searches I finally found. I have to use the tonumber(arg[,base]) function. In my case, base = 16.
And if you open the utils-auto4.lua from the automation directory of some Aegisub pre-realease, you can find lots of useful information
__________________
Après la tempête, le calme éphémère...

Last edited by OpeTh; 2007-08-05 at 16:17.
OpeTh is offline   Reply With Quote
Old 2007-08-06, 00:33   Link #487
edogawaconan
LOL?
*Fansubber
 
 
Join Date: Aug 2006
Location: Indonesia
Send a message via MSN to edogawaconan Send a message via Yahoo to edogawaconan
Quote:
Originally Posted by Zanejin View Post
...rather than what? Lua is the core of simple karaoke generation in Aegisub. It's flexible and rather easy.
if it's only adding something to each line and shifting times, with constant numbers, find and replace and shift times will do just fine

oh well, let's end this here.
edogawaconan is offline   Reply With Quote
Old 2007-08-06, 02:47   Link #488
Zanejin
Junior Member
*Fansubber
 
 
Join Date: Jun 2007
Quote:
Originally Posted by edogawaconan View Post
if it's only adding something to each line and shifting times, with constant numbers, find and replace and shift times will do just fine

oh well, let's end this here.
Actually, many karaoke stylers frequently need to, for the next-simplest effects, use start and end times, together with durations, of syllables and lines. All of these are calculated by the Lua scripting.
__________________
Zanejin is offline   Reply With Quote
Old 2007-08-06, 09:03   Link #489
Sylf
翻訳家わなびぃ
*Fansubber
 
 
Join Date: Nov 2003
Age: 40
Send a message via MSN to Sylf Send a message via Yahoo to Sylf
Quote:
Originally Posted by Zanejin View Post
Actually, many karaoke stylers frequently need to, for the next-simplest effects, use start and end times, together with durations, of syllables and lines. All of these are calculated by the Lua scripting.
Karaoke effects, sure. But for that kind of simple effects, the included scripts like simple-k-replacer is good enough for most cases. And for placing a static string like constant \fad, using find/replace function works just well for most cases. With a virgin script, we can replace the string 0000,0000,0000,, with 0000,0000,0000,,{\fad(xxx,yyy)}. (OK, it'll start breaking when we start putting things like margin override, the line command like scrolls, etc... that's why I said virgin script.) Probably there are some of us who wonder why some people like creating Lua script to accomplish such a simple task.
Sylf is offline   Reply With Quote
Old 2007-08-06, 14:10   Link #490
jfs
Aegisub dev
 
 
Join Date: Sep 2004
Location: Stockholm, Sweden
Age: 30
This is going a lot off-topic, but everyone should learn at least some basic regular expressions. You can do a lot of fancy things with it.

In Aegisub, in Search & Replace, you can enable regular expressions and do this replacement:
Search for: ^
Replace with: {\fad(xxx,yyy)}
That will search for every start of line (that's what the ^ character in regular expressions means) and "replace" it with the text given. Of course the start of line doesn't disappear, the effect is simply that the given text is placed at the beginning of each line.

You can extend this procedure to only affect some lines by selecting them beforehand and letting the replacement run over only selected lines. Optionally you can use the "Select Lines" function to do some automated, conditional selection of lines.
__________________

Aegisub developer [ Forum | Manual | Feature requests | Bug reports | IRC ]
Don't ask for: More VSFilter changes (I won't), karaoke effects, help in PM's
jfs is offline   Reply With Quote
Old 2007-08-07, 05:54   Link #491
OpeTh
Fansub PowA
 
 
Join Date: Jul 2007
Location: Cranfield - UK
Age: 29
Thanks jfs for this kind of tip. I really didn't know something about "regular expressions", that is why I tried to made it with a lua script.
If you have some other regular expressions to give, it will be heplful for many of us I think
__________________
Après la tempête, le calme éphémère...
OpeTh is offline   Reply With Quote
Old 2007-08-07, 18:20   Link #492
Sylf
翻訳家わなびぃ
*Fansubber
 
 
Join Date: Nov 2003
Age: 40
Send a message via MSN to Sylf Send a message via Yahoo to Sylf
Google for "regular expressions primer". That'll go for a very very long way.
Sylf is offline   Reply With Quote
Old 2007-08-16, 03:04   Link #493
Twice Twisted
Disabled By Request
 
Join Date: Jan 2007
I have some question about karaoke in Aegisub. May be someone from community already fix it.

Problem with incorrect placement of syllables in new Karaoke Templater from 2.0 alpha. I tested that and it works fine with 1.10's line-per-syllable, but I'm using Linux and only 2.0 are available.

I'm using "template syl" in effect field and "{\pos($x,$y)}" in message.

So, I have BEFORE image:


And AFTER:


How to fix it? I need letters like on BEFORE image, but not additional spaces from AFTER.
Twice Twisted is offline   Reply With Quote
Old 2007-08-16, 07:04   Link #494
jfs
Aegisub dev
 
 
Join Date: Sep 2004
Location: Stockholm, Sweden
Age: 30
Unfortunately, I don't have any fix for the sizing/positioning issues on anything but Windows ATM. It'd be a bit of work to make it right and I don't have the environment to write and test the correct sizing calculation code atm., so the text_extents function in Automation will have to remain broken for now. Sorry

A possible workaround for the time being would be to manually determine the scaling factor that makes the positioning right, ie. the number to multiply the syllable position relative to the left edge of the line, syl.left, syl.center and syl.right, and calculate the new line position too.
The scaling differs per font face and needs to be extracted from the TrueType headers. This can be done with FreeType2, but I'd still need a text layout library to get it right.
__________________

Aegisub developer [ Forum | Manual | Feature requests | Bug reports | IRC ]
Don't ask for: More VSFilter changes (I won't), karaoke effects, help in PM's
jfs is offline   Reply With Quote
Old 2007-08-16, 09:26   Link #495
Twice Twisted
Disabled By Request
 
Join Date: Jan 2007
I hope that you will fix it in the future ;-)

Last edited by Twice Twisted; 2007-08-16 at 09:27. Reason: mistake
Twice Twisted is offline   Reply With Quote
Old 2007-08-16, 11:04   Link #496
jfs
Aegisub dev
 
 
Join Date: Sep 2004
Location: Stockholm, Sweden
Age: 30
I just committed a patch to Aegisub that should make text_extents on non-Windows be almost correct in most cases. It might still be slightly off in some corner cases, but I think it'll be "good enough" for most work now.
jfs is offline   Reply With Quote
Old 2007-08-17, 00:38   Link #497
Twice Twisted
Disabled By Request
 
Join Date: Jan 2007
Fine. I tested it. Works. Thank You.
Twice Twisted is offline   Reply With Quote
Old 2007-08-18, 00:53   Link #498
Katsuyu
Junior Member
 
Join Date: Jan 2007
guys....

how can i put the letter in the right place like:

{\an5\move(%d,%d,%d,%d)}
or

{\pos($X,40)}
Katsuyu is offline   Reply With Quote
Old 2007-08-22, 00:38   Link #499
Skyward
Oblivious
*Fansubber
 
 
Join Date: Jul 2007
I've been teaching myself some simple karaoke using automation 4 over the past few days. Simple meaning I have no idea how to write lua scripts yet. I've recently come across an obstacle that I am unsure of how to accomplish without learning lua scripting.

I have a bunch of lines with effects (\t tags specifically) already in the line (in addition to the \k tags), and I would like to have one layer preserve the effects while the rest obliterate them.

Is this possible to accomplish without needing to learn lua scripting? And if so, how can this be done?
Skyward is offline   Reply With Quote
Old 2007-08-22, 01:03   Link #500
Sylf
翻訳家わなびぃ
*Fansubber
 
 
Join Date: Nov 2003
Age: 40
Send a message via MSN to Sylf Send a message via Yahoo to Sylf
http://aegisub.cellosoft.com/docs/Karaoke_Templater

With the scripts provided with aegisub, you don't need to learn lua. You only need to learn how to use the provided script. Start with the simple example on that page and get yourself comfortable using it.
Sylf is offline   Reply With Quote
Reply

Tags
fansubbing, karaoke, software, subbing

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 07:57.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
We use Silk.