• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Final fantasy X translation system

Didjynn

Member
Hello everyone,

I had today a big problem and I don't know how to get rid of it.

I wanted to create a "simple" translation system in my game. You can find books that use a font with symbols so it's unreadable. We can discover the meaning of some letters and so some letters in the sentence would be translated and not the others. In Final Fantasy, a Z could become a B after translation. Yup easy encoding :p
Code:
var str = string_ord_at(txt, typespeed)
       //show_debug_message("str = " + string(str))
       if tbltranslate[str] = 1 {
           lettreconnue = 1
       }else{
           lettreconnue = 0
       }
this code can tell me for each letter if I already know it but the problem is when I want to draw the sentence...
Because you can only change the font before and after your sentence, not inside of it so in the end the full sentence will be translated or totally not translated, you can't just translate one letter after another.

If anyone have a better idea than mine, would be nice if it could be done in few lines I'm trying to make a clean work.

Thank you for your time and help :)
 

obscene

Member
Personally I'd do something like this (theory, never done it).

1. Create an array from your string of individual letters. Example...

"Test" becomes
array[0]="T"
array[1]="e"
array[2]="s"
array[3]="t"

2. Create a script that takes 1 letter, checks if it's been translated and then overwrites the value in the array. Don't forget to see if a letter is capitalized and reapply that.

3. After processing entire array, assemble the array values back into a string and draw it.

No time to go more in-depth but give it a go and I'll help along the way.
 

Didjynn

Member
Hello, thx for your answer :)
I've already done this part and it's working fine, my problem is when I need to draw the half translated sentence because if I use draw text and change the font before it will change all the sentence when I want to change only some letters.
I'm trying to find a clean way to draw that but it seems complicated to me even with a "for" drawing each letter, they will look separate from other letters. The other problem is : the text is quite big, hard to do something clean without a draw_text_ext
Ex :
Code:
for ( i = 0; i < txtlength; i ++) {
    draw_text(x + i*4, y, written)
}
I also use a code to write the text letter by letter like if it was typing.
 

obscene

Member
Oh ... sorry. You're using a different font to symbolize the other language? That get's harder man, you'll have to build a system that draws a few letters, tracks the width of the string and knows where to begin the next letter. Not fun!
 

TheouAegis

Member
Here's how I'd do this:

Your font would have 26 glyphs and 26 letters -- all capital for simplicity. The glyphs would start at chr(65) which is "A" in the font. The letters would start at chr(97) which is "a" in the font. Generate a random cipher when the player selects NEW GAME so each letter is encrypted differently with each playthrough (optional).
Code:
randomize();
global.cipher = ds_list_create();
for(var i=0; i<26; i++) 
    global.cipher[| i] = chr(i+65);
ds_list_shuffle(global.cipher);
Have all the text written in capital letters by default.

Have an array of each letter to keep track of when it has been translated (since this is essentially a set of boolean flags, you could just use a single array and set the bits, but they don't want me pushing that method here).
Code:
for(var i=0; i<26; i++) global.Arcana[i] = false;
When you learn what a glyph translates to, set its corresponding arcanum to true. E.g.:
Code:
global.Arcana[4] = true;
When the player reads text from an encrypted book or whatever, fetch the text and then translate it letter by letter.
Code:
///get_display_text(index)
var str = Texts[argument0];
for(var i=0; i<26; i++)
    if global.Arcana[i] 
        str = string_replace_all(str, chr(i+65), chr(i+97));
    else
        str = string_replace_all(str, chr(i+65), global.cipher[| i];  //optional if you used the cipher
return str;
So all the capitalized letters will either be lowercased (and so displayed as translated) or will be kept capital and thus encrypted (and optionally further encrypted if you used the cipher).
 

Didjynn

Member
Hey, thx for your answer !

I understand your code and yes I think it could work but I find it a little complicated. I finally found a way...

The problem with using "for" is that it will break my typing effect except if I create extra variables to take care of this but I found another way :
I write the text 2 times, one time I write only the decoded text, the other time I write only the undecoded text (I add a space on the decoded line everytime the letter is unknown and of course it's the same story for the undecoded text). 2 lines on the same place, it's not perfect but it sounds good enough for now. I will come back here to tell if it's as good as I expect it to be once polished.

Thx for your time :)
 
Top