Localised names

Place to get help with not working mods / modding interface.
Post Reply
User avatar
oLaudix
Filter Inserter
Filter Inserter
Posts: 282
Joined: Sun Jun 14, 2015 3:24 pm
Contact:

Localised names

Post by oLaudix »

Is there a way to get localised name of ie. recipe in control.lua?
Image

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Localised names

Post by Adil »

game.player.print method converts the lua name to localised. It is even capable of concatenating those.
They're probably inaccessible other way.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

User avatar
oLaudix
Filter Inserter
Filter Inserter
Posts: 282
Joined: Sun Jun 14, 2015 3:24 pm
Contact:

Re: Localised names

Post by oLaudix »

Adil wrote:game.player.print method converts the lua name to localised. It is even capable of concatenating those.
They're probably inaccessible other way.
This sux :/ Its not even helpful for print since i would need it to be dynamic not static :/
Image

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Localised names

Post by Adil »

oLaudix wrote: i would need it to be dynamic not static :/
You didn't actually look at the wiki page, did you?
Or is my definition of dynamic different from your?
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

User avatar
oLaudix
Filter Inserter
Filter Inserter
Posts: 282
Joined: Sun Jun 14, 2015 3:24 pm
Contact:

Re: Localised names

Post by oLaudix »

Adil wrote:
oLaudix wrote: i would need it to be dynamic not static :/
You didn't actually look at the wiki page, did you?
Or is my definition of dynamic different from your?
Its impossible to do:

Code: Select all

for i,ingredient in pairs(recipe.ingredients) do
local a = ingredient.name
game.player.print({"entity-name.a"})
end
or any other combination of ingredient.name variable. I looked at wiki page and its whooping 5 lines of code, so loose some attitude pal. If you see something other person doesnt then explain instead being a prick.
Image

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Localised names

Post by Adil »

Well, among those file lines of code are three, which are a part of working mod:

Code: Select all

a='entity-name.gun-turret'
game.player.print({a})
game.player.print({"",{a}," is destroyed"})
(Even more, in real mod it's concatenation of two localized strings.)

Your code should be like this to work:

Code: Select all

for i,ingredient in pairs(recipe.ingredients) do
local a = "item-name."..ingredient.name
game.player.print({a})
end
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

User avatar
oLaudix
Filter Inserter
Filter Inserter
Posts: 282
Joined: Sun Jun 14, 2015 3:24 pm
Contact:

Re: Localised names

Post by oLaudix »

Adil wrote:Well, among those file lines of code are three, which are a part of working mod:

Code: Select all

a='entity-name.gun-turret'
game.player.print({a})
game.player.print({"",{a}," is destroyed"})
(Even more, in real mod it's concatenation of two localized strings.)

Your code should be like this to work:

Code: Select all

for i,ingredient in pairs(recipe.ingredients) do
local a = "item-name."..ingredient.name
game.player.print({a})
end
See? You clearly saw something I didn't. I wont apologise for not knowing everything. I will thank you for the code thought, it works exacly as i need.

I found that

Code: Select all

game.item_prototypes[ingredient.name].localised_name
also works.
Image

Post Reply

Return to “Modding help”