Problems getting the Localized Names of Items
Posted: Mon Sep 07, 2026 5:55 pm
While working on one of my mods, I'm having trouble understanding something.
In the mod, I display a list of items in a GUI. The localized names of the items are shown as their names. I determine the localized names using the following code, based on the items’ internal names contained in a table generated by the mod:
I add the localized names of the items to the list in the GUI using the following code:
That works fine.
Now, as part of the updates for Factorio version 2.1, I want to add a sorting function to the list of items in the mod. So I took the variable described above, which contains the supposed localized names of the items, and wanted to add the localized names to the table so I could sort by them. However, the localized names aren’t being added to the table. When I try to print the contents of the variable to the console using the following code, it outputs “table.”
Now I’m a bit confused, because the localized name is displayed correctly in the GUI list, but I apparently can’t insert it into a table. What am I doing wrong? Or how can I use the internal name to transfer the localized name to a variable or add it to a table?
In the mod, I display a list of items in a GUI. The localized names of the items are shown as their names. I determine the localized names using the following code, based on the items’ internal names contained in a table generated by the mod:
Code: Select all
local myLocalName = prototypes.item[myTable[i].name].localised_nameCode: Select all
my_gui_table.add{type = 'label', caption = myLocalName, style = 'bold_label'}Now, as part of the updates for Factorio version 2.1, I want to add a sorting function to the list of items in the mod. So I took the variable described above, which contains the supposed localized names of the items, and wanted to add the localized names to the table so I could sort by them. However, the localized names aren’t being added to the table. When I try to print the contents of the variable to the console using the following code, it outputs “table.”
Code: Select all
myPlayer.print(tostring(myLocalName))