Jump to content
Następne podsumowanie tygodnia pojawi się 21.09 | The next summary of the week will be published on 21.09

How to get rig of hash symbol in strings displayed by DisplayMessage function?


Rafał

Recommended Posts

Whenever I send strings directly in lua to function DisplayMessage or DisplayChatText my end result always begins with '#' in game.

simrail_string_hash.png.824e417c415714aef55f91b038495d45.png

It's not a big deal but as a perfectionist I simply do not like it, can I do something about it?

Code for comparison:

DisplayMessage('Witaj '.. GetUsername() ..'!' .. '\nW dzisiejszym scenariuszu zrobisz totalnie nic', 10)

 

Link to comment
Share on other sites

  • SIMRAIL Team

Hello

You have to set key in your specific language file in Locales folder. So for example for polish it will be pl.lang with key like this
 

HelloMessage=Your text

And then use it in DisplayMessage function like this

DisplayMessage("HelloMessage")

Remember that you also need the main en.lang file if your scenario doesn't support all languages available in SimRail, then it will be used as default language file.

More information about file structure you can find here.

  • I agree 1
Link to comment
Share on other sites

5 godzin temu, s0n1c napisał(a):

You have to set key in your specific language file in Locales folder

True, I've noticed it, but using locale files I cannot call function GetUsername() and marge it with string from lang file, or am I wrong?

Link to comment
Share on other sites

  • SIMRAIL Team

To make this possible you should use DisplayMessage_Formatted function, where {x} is replacement for your GetUsername function.
For example key in locales should look like:

Message=Welcome {0} in this scenario

and the code with DisplayMessage_Formatted:
 

DisplayMessage_Formatted("Message", 10, GetUsername())

Replacements in key should be defined in range  from 0 to 4, that means you have limit of 5 replacements for 1 key.

  • Like 1
  • I agree 1
Link to comment
Share on other sites

Do I have to declare those lang files somewhere, or are they loaded automatically if only game will find them in 'Locales' folder? Because it doesnt work for me...

 

cango1.thumb.png.992ae89967583a548979cc06defb59b4.png

Link to comment
Share on other sites

  • SIMRAIL Team
W dniu 13.05.2024 o 09:21, s0n1c napisał(a):

Remember that you also need the main en.lang file if your scenario doesn't support all languages available in SimRail, then it will be used as default language file.

They are loaded automatically from Locales folder, but the problem you have is basically what i have mentioned here. You are missing default language file which is en.lang.

Make sure all language files should have the same structure, that means your key Cango should be in both pl.lang and  en.lang files.

 

  • Like 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use Privacy Policy