Page 1 of 1

[1.1.74] Localised item name is not found for some items

Posted: Fri Dec 30, 2022 9:10 pm
by punapantteri
I am developing a mod that displays resource objectives. However, pipe-to-ground does not return the localised item name:
objective.png
objective.png (168.54 KiB) Viewed 834 times

To demonstrate the issue more easily, here's how to replicate it in the command prompt / in-game chat.

When I run this, everything works as expected:

Code: Select all

/c game.print({"item-name.iron-plate"})
command1.png
command1.png (119.15 KiB) Viewed 834 times

However, when I run this, it doesn't work:

Code: Select all

/c game.print({"item-name.pipe-to-ground"})
command2.png
command2.png (109.99 KiB) Viewed 834 times

Same problem for at least pipe and small-electric-pole.

I would expect them to to output/return the same string as this code does, just without icon, the brackets and the "Item:" text.

Code: Select all

/c game.print("[item=pipe-to-ground" .. "]")
(Concatenation is added so that Factorio's chat doesn't reformat the command string in the screenshot.)
command3.png
command3.png (112.5 KiB) Viewed 834 times

In other words, I think the second code snippet should print "Pipe to ground".

Should I use something other than {"item-name..."} for getting the localised name of the item?

Re: [1.1.74] Localised item name is not found for some items

Posted: Sat Dec 31, 2022 7:51 pm
by Rseding91
Thanks for the report however this is correct. There is no localization for those items. They get their name from the entity that those items build. Since iron plate does not build anything it does have a localized name defined for the item.

Re: [1.1.74] Localised item name is not found for some items

Posted: Wed Jan 11, 2023 8:47 am
by punapantteri
Thank you for the response, it helped me figure this out.

Adding this here in case someone has the same need later.

Arbitrary item name localisation can be done with this code:

Code: Select all

game.item_prototypes["pipe-to-ground"].localised_name
Source: viewtopic.php?p=211060#p211060