Translate code, not working?

Jochum

Member
Hi, I've tried to create a code for a game translation myself.
Unfortunately, it's not working. The translation_counter is working but it's not getting the right translation to it. How can I fix this?

Code:
 //Create Code
//Set Total Translations
total_translations = 3;

//Set translation counter
translation_counter = 0;

//Set Translations
translation[0,0] = "Play";
translation[1,0] = "Speel";
translation[2,0] = "Spielen";

translation[0,1] = "Options";
translation[1,1] = "Instellingen";
translation[2,1] = "Einstellungen";

//Switch Between Translation
switch (translation_counter){
    case 0:    //English
        {
            lang_play = translation[0,0];
            lang_options = translation[0,1];
            break;
        }
    case 1:    //Dutch
        {
            lang_play = translation[1,0];
            lang_options = translation[1,1];
            break;
        }
    case 2:    //German
        {
            lang_play = translation[2,0];
            lang_options = translation[2,1];
            break;
        }
    default:    break;
    }
Code:
 //Step Code
if keyboard_check_pressed(vk_right) or keyboard_check_pressed(ord("D"))
    {
        translation_counter += 1;
    }

if keyboard_check_pressed(vk_left) or keyboard_check_pressed(ord("A"))
    {
        translation_counter -= 1;
    }

if translation_counter < 0
    {
        translation_counter = total_translations;
    }

if translation_counter > 3
    {
        translation_counter = 0;
    }
Code:
 //Draw Code
//Draw translation_counter
draw_set_color(c_white);
draw_set_font(font0);
draw_text(room_width/2,room_height/2,string(translation_counter));
draw_text(room_width/2,room_height/2 - 100 ,string(lang_play));
 

Tornado

Member
your whole
switch (translation_counter) block must be in the step event.

Like you have it now it is executing only once when object is created!

EDIT:
But generally avoid having it in the step event if you don't really need it there.
If language change is triggered by an option then just change the language variable (translation_counter) there and when displaying text in your game don't use
draw_text(room_width/2,room_height/2 - 100 ,string(lang_play));
but
draw_text(room_width/2,room_height/2 - 100 ,scr_translate(lang_play));
and in this new script scr_translate(key) you put your code "Switch Between Translation"
 
Last edited:

FrostyCat

Redemption Seeker
You are setting the translated text in the Create event only, that won't come around to run again when you change translation_counter later.

Move the "Switch Between Translation" part to User Event 0, then run event_user(0); in the Create event and everywhere translation_counter is being changed.
 
Top