Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Darky on October 24, 2009, 06:15:19 PM

Title: Language String doesnt work?
Post by: Darky on October 24, 2009, 06:15:19 PM
I wanted to do multiple messages on the quit window for when the user quits the game. I therefore named the message field in quit.window "quitmsg"
Then in quit.script I wrote:

Code: WME Script
  1. // set a random quit text every time
  2. var QuitMsg = new Array();
  3. QuitMsg[0] = "/QUIT0001/Testtext 1";
  4. QuitMsg[1] = "/QUIT0002/Testtext 2";
  5. QuitMsg[2] = "/QUIT0003/Testtext 3";
  6. QuitMsg[3] = "/QUIT0004/Testtext 4";
  7. QuitMsg[4] = "/QUIT0005/Testtext 5";
  8.  
  9. // get control over the quit text to insert the random new one
  10. var QuitText = this.GetControl("quitmsg");
  11. QuitText.Text = QuitMsg[ Random(0, 4) ];
  12.  

The corresponding messages are also in string.tab

It indeed displays the texts in the window now but only the texts I defined in the array, for example: /QUIT0005/Testtext 5
So it displays just what I have in the array. I even changed the texts from the string table and it just ignores it.

What goes wrong?
Title: Re: Language String doesnt work?
Post by: metamorphium on October 25, 2009, 12:40:03 PM
Normally you can assign translated string this way:
Code: WME Script
  1. QuitMsg[0] = Game.ExpandString("/QUIT0001/Testtext 1");
  2. // etc...
  3.  

or even better in your case (centralized translation)

Code: WME Script
  1. QuitText.Text = Game.ExpandString(QuitMsg[ Random(0, 4) ]);
  2.  
Title: Re: Language String doesnt work?
Post by: Darky on October 25, 2009, 12:53:53 PM
Perfect, that works fine! Thank you so much!

Another thing learned ;D