Hi,
How can I localize item name when I don't know the type of an item? Like, is it entity, equipment or simple item?
Say, there is ghost entity that is blocked by laying around items. When my script revives ghost entity, I want to put these items into player's inventory and to show flying text "+10 Iron plate (50)" like in vanilla game when you build entity over items on the ground.
Problem is, I have item names only and don't know how to convert them into localised strings, because their names are grouped by types for some reason, like: 'item-name.pistol', 'entity-name.splitter' or 'equipment-name.battery-equipment'.
Its strange how entities and equipment have respective item prototypes but don't have 'item-name.###' localisation strings.
PS. Also, revive() function does a good job returning list of removed items from ground with their respective count, however all item specific information (health, clip rounds, armour equipment, etc.) is lost. But that's something I'm trying not to think about right now.
How to localize arbitrary item name?
- akastalker
- Burner Inserter
- Posts: 12
- Joined: Mon Jun 27, 2016 10:52 pm
- Contact:
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: How to localize arbitrary item name?
Here's everything I know about localisation: https://github.com/aubergine10/Style/wiki/Localisation
In particular, look under the 'Parameters', 'Special Parameters' and 'Nested locale objects' headings.
In particular, look under the 'Parameters', 'Special Parameters' and 'Nested locale objects' headings.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
- akastalker
- Burner Inserter
- Posts: 12
- Joined: Mon Jun 27, 2016 10:52 pm
- Contact:
Re: How to localize arbitrary item name?
This is a wonderful tutorial, but it didn't help me.
In my script I have name of an object that I just picked up from the floor, and I don't know what that object is: item, entity or equipment.
I know, everything that can go into player's inventory is an item, or at least has an item counterpart,
but base mod localisation file contains only one 'stone-furnace' that is in section [entity-name] and don't have 'item-name.stone-furnace'.
I tried that __ITEM__stone-furnace__ thing and still getting "Unknown key: "item-name.stone-furnace"".
I wonder, how game engine handles localisation of items in inventory GUI...
So, still looking for solution.
In my script I have name of an object that I just picked up from the floor, and I don't know what that object is: item, entity or equipment.
I know, everything that can go into player's inventory is an item, or at least has an item counterpart,
but base mod localisation file contains only one 'stone-furnace' that is in section [entity-name] and don't have 'item-name.stone-furnace'.
I tried that __ITEM__stone-furnace__ thing and still getting "Unknown key: "item-name.stone-furnace"".
I wonder, how game engine handles localisation of items in inventory GUI...
So, still looking for solution.
Re: How to localize arbitrary item name?
akastalker wrote: So, still looking for solution.
http://lua-api.factorio.com/latest/LuaI ... lised_name
Example:
Code: Select all
/c game.player.print(game.item_prototypes["iron-plate"].localised_name
- akastalker
- Burner Inserter
- Posts: 12
- Joined: Mon Jun 27, 2016 10:52 pm
- Contact:
Re: How to localize arbitrary item name?
Wow, wasn't aware I had access to prototypes in runtime. It's an eye opener, thank you.
@aubergine18, can you update your tutorial to include this approach?
Consider case closed.
@aubergine18, can you update your tutorial to include this approach?
Consider case closed.
- Ranakastrasz
- Smart Inserter
- Posts: 2173
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Re: How to localize arbitrary item name?
You don't. Just a subset of the prototype.akastalker wrote:Wow, wasn't aware I had access to prototypes in runtime.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Re: How to localize arbitrary item name?
Not for items. For items it's all of the properties every item prototype has.Ranakastrasz wrote:You don't. Just a subset of the prototype.akastalker wrote:Wow, wasn't aware I had access to prototypes in runtime.
If you want to get ahold of me I'm almost always on Discord.