Page 1 of 1
Newlines in material
Posted: 19 Dec 2012 14:07
by Aphid
It has come to my attention that a lot of the means script uses to present data to users does not support newlines. News messages and the town info window text both do not display default '\n' characters as newlines, but will instead display '?'.
Re: Newlines in material
Posted: 19 Dec 2012 17:37
by frosch
"?" is displayed for every invalid character which is filtered by the validator.
The control code for new line in strings/translations is "{}". See
http://wiki.openttd.org/Format_of_langf ... slations_2
Re: Newlines in material
Posted: 20 Dec 2012 09:00
by Aphid
Are you sure?
Please check the two attached files.
It seems that just a basic non-text object string does not properly communicate '{}' either.
Re: Newlines in material
Posted: 20 Dec 2012 17:34
by Zuu
Indeed, {} and other control strings only works when used in translations. Using {} in a literal string to produce a new line in a .nut file will not work.
However, even if your script is only available in English, using lang/english.txt, you will already prepare your script so that it is easy for a non-programmer to contribute a translation of your script.
Re: Newlines in material
Posted: 21 Dec 2012 00:41
by Aphid
If only I could do that...
But you see, there is but a slight problem. OpenTTD has 32 cargoes.
This means the string in question has up to 36 lines, 32 with 3 elements in them. That means it has up to around 110 sub-elements.
That's more than 20, the maximum for a GSText object. Since GSTown's line only accepts a single object it cannot be cut into multiple pieces either.
Thus I cannot use the english.txt.
Which leaves us with a dilemma, basically. Various solutions to it would be fine:
1) Somehow remove or raise to absurd amounts all length limitations from the string generation. E.g. have proper recursion. **
2) Somehow properly display "\n". The log does it, so why wouldn't other constructs?
3) Somehow allow objects that present to the user a single string object to instead (also) be able to present a table, list, and/or array of string objects.*
* Obviously, signs already provide this functionality by building multiples of them. The same goes for the Goal interface. But the Town window and News messages are not so well-equipped to deal with it.
** Increase SCRIPT_TEXT_MAX_PARAMETERS = 20 to maybe 300?
Either (1), (2), or (3) would provide a fix.