Translations of this page:

talk lines, one line in string.tab

I had this thought.
When you're translating a sentance from one language to another, it might not have the same structure, and i wanted to be able to keep a few sentances grouped together in one talk.

Lets say my actor wants to say:
“Hello.”
“My name Is Guybrush Threepweeod.”
“I want to be a pirate.”

I'd write in my code

actor.Talk("/GUYBRUSH_HELLO_00/Hello"); 
actor.Talk("/GUYBRUSH_HELLO_01/My name Is Guybrush Threepweeod."); 
actor.Talk("/GUYBRUSH_HELLO_02/I want to be a pirate.");

and in string.tab i'd have:

GUYBRUSH_HELLO_00       Hello. 
GUYBRUSH_HELLO_01       My name Is Guybrush Threepweeod. 
GUYBRUSH_HELLO_02       I want to be a pirate.

and i'd have 3 files GUYBRUSH_HELLO_00.ogg GUYBRUSH_HELLO_01.ogg GUYBRUSH_HELLO_02.ogg.

but i was thinking, maybe when translating it, you need more then 3 sentances ? or maybe 2 are enough.
So, i didn't want to need to keep a diffrent code for each language, but to group all these 3 into one line.
But how do i split them so the actor will say each line, and that i'd have 3 seperate audio files ?

i wrote this talk method, you can put it in your actor script file:

method Talk(inString) 
{ 
    // get the input string and split it into the tag and value with / 
    var myStr = new String(inString); 
    var SplitArr = myStr.Split("/"); 
    // if it's not in format ("/aaa/bbb")  say it as it 
    if (SplitArr.Length < 2) { 
        this.Talk(inString); 
        return; 
    } 
    // get it form the string.tab 
    var expanded = Game.ExpandString(inString); 
 
    // split it for parts with \ in them 
    // i assume expanded splited will only have 1 item if it's missing from string.tab so we'll treat it as single. 
    var expandedStr = new String(expanded); 
    var SplitArr2 = expandedStr.Split("\"); 
    // if it's a one liner say it as it is. 
    if (SplitArr2.Length < 2) { 
        this.Talk(inString); 
        return; 
    } 
 
    // say each part and play sound for it with TAG_NAME_00 etc.. 
    for (var i= 0; i < SplitArr2.Length; i = i+1){ 
        var fmti; 
        if (i < 10) { 
            fmti = "0" + i; 
        }  else { 
            fmti = i; 
        } 
        var outString = "/" + SplitArr[1] + "_" + fmti + "/" + SplitArr2[i] ; 
        this.Talk(outString); 
    } 
 
}

Now, i also want to make sure that i have all my strings in my string.tab so instead of the text hardcoded i write “MISSING_TEXT BLABLABLA” so i'd know what's missing when i do QA work.
so now what i have is :

actor.Talk("/GUYBRUSH_HELLO/MISSING TEXT GUYBRUSH_HELLO");

and in string.tab

GUYBRUSH_HELLO       Hello.\My name Is Guybrush Threepweeod.\I want to be a pirate.

and i keep my original recorded files GUYBRUSH_HELLO_00 through 02 and it works like a charm.

Note, Initially i wanted to use | for line seperator, but WME already changes it into a \n. which is undocumented as far as i know, and you can't split a string easily with two characters without writing another function.

SoundGuy

 
resource/talk_lines_one_line_in_string.tab.txt · Last modified: 2009/08/13 19:54 by Darky
Recent changes RSS feed Creative Commons License Driven by DokuWiki