Transport Fever

Transport Fever

View Stats:
_("strings") in LUA
This is the kind of question that's hard to tell Google what you're looking for:

What's the difference in LUA between a "string" and a _("string") ?
< >
Showing 1-4 of 4 comments
RabbitRidge Feb 2, 2019 @ 10:08pm 
I don't understand your question, a string should the same any coding language context. Perhaps you could be more specific. Are you referring to some specific LUA function?

Perhaps you are referring to passing variables to another function (within parentheses which can be internal or external in scope).
SoftwareSimian Feb 3, 2019 @ 7:40am 
I'm new to LUA since starting modding for TransportFever, so I'm just learning as I go based on extant code samples from the vanilla game and other mods. In some places I see strings quoted with either 'single' or "double" quotes which is fine, as well as there [[heredoc style]].
But in some places where I expect a string I see values not just in a doublequoted string, but also wrapped inside what looks like an underscore function. For example, quoting from /mods/urbangames_no_costs_1/mod.lua
severityRemove = "NONE", name = _("No costs"),
the first is a normal string, but why is name written as _("No costs") instead of just "No costs" ?
This is by no means an isolated example, it's all over the place, I'm just citing a specific example for clarity.
Last edited by SoftwareSimian; Feb 3, 2019 @ 7:42am
JK Feb 3, 2019 @ 7:42am 
I believe _("string") is one that is intended to translated into another language via a translation file in the mod folder that the game will hand. E.g. it might be in English in your code, but the translation file could have the equivalent in German language.

If you're not intending it to be translated then just use "string" (although _("strings") without a translation file wouldn't cause any error to my knowledge).
Last edited by JK; Feb 3, 2019 @ 7:43am
SoftwareSimian Feb 3, 2019 @ 7:55am 
Aha! Thank you sir! I haven't actually tried that in code yet, but I think that makes sense. Now I'm going to have to translate my mods :)

edit: I have now tested it and that does indeed work. It all makes sense now. Thanks JK!
Last edited by SoftwareSimian; Feb 3, 2019 @ 8:10am
< >
Showing 1-4 of 4 comments
Per page: 1530 50