Page 1 of 1

How to concat to localized string?

Posted: Thu Aug 10, 2017 5:03 am
by d3x0r
Say I have a mod that checks to see if you have enough items for a recipe in your inventory, and want to report

"{You-are-missing} X (localized-string)" to the player....

or like this....

player.print( (ingred.amount*n).."x ".. ingred.name );

Re: How to concat to localized string?

Posted: Thu Aug 10, 2017 5:26 am
by DaveMcW

Re: How to concat to localized string?

Posted: Thu Aug 10, 2017 9:53 am
by d3x0r
Thanks. It's important that the first item in the list be a string, and not a localization sub-string...

Code: Select all

-- levels is recursive levels of a routine for instance....

local leader = { "" };
for i = 1,levels do
   leader[#leader+1] = "--+";
end
leader[#leader+1] =  {"item-name."..item}, {"times_x"},

player.print( { "", leader, {"item-name."..item}, {"times_x"},  " and ", } );

*shrug* something like that... can actually have lots of levels of nested concatenations.

How to insert a line-break ? :)

Re: How to concat to localized string?

Posted: Thu Aug 10, 2017 10:12 am
by Nexela
If wherever you are using it supports line breaks, "\n"

Re: How to concat to localized string?

Posted: Thu Aug 10, 2017 10:19 am
by d3x0r
Nexela wrote:If wherever you are using it supports line breaks, "\n"
player.print didn't ... it just left it as one long line; I ended up just doing multiple prints and building a array of lines instead of one line with linebreaks.