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

Bugs that are actually features.
punapantteri
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Jan 10, 2022 9:42 pm
Contact:

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

Post 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 830 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 830 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 830 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 830 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?

Rseding91
Factorio Staff
Factorio Staff
Posts: 14046
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.

punapantteri
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Jan 10, 2022 9:42 pm
Contact:

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

Post 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

Post Reply

Return to “Not a bug”