How to concat to localized string?

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

How to concat to localized string?

Post 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 );


d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

Re: How to concat to localized string?

Post 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 ? :)

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: How to concat to localized string?

Post by Nexela »

If wherever you are using it supports line breaks, "\n"

d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

Re: How to concat to localized string?

Post 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.

Post Reply

Return to “Modding discussion”