Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Multiple talk, one line in string.tab  (Read 2368 times)

0 Members and 1 Guest are viewing this topic.

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
Multiple talk, one line in string.tab
« on: August 31, 2006, 10:57:06 PM »

I had this tough.
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

Code: [Select]
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:
Quote
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:

Code: [Select]
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 :


Code: [Select]
actor.talk("/GUYBRUSH_HELLO/MISSING TEXT GUYBRUSH_HELLO");

and in string.tab
Quote
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
Logged
 

Page created in 0.165 seconds with 17 queries.