Locale strings from data.lua
Locale strings from data.lua
I've tried searching for this, but I could not find it.
I have a mod that adds a bunch of entities based on already existing entities in the data.raw, to support the behavior I want to provide. Now the items show up as "unknown key [bla]". For the base game items I can provide a locale file. But I rather have my mod work with other mods as well. So is it possible to set something in to prototype it uses locales from a different object name? My new objects are not distinguishable from the "base" object by nature. Or provide the English locale from the data.lua?
I have a mod that adds a bunch of entities based on already existing entities in the data.raw, to support the behavior I want to provide. Now the items show up as "unknown key [bla]". For the base game items I can provide a locale file. But I rather have my mod work with other mods as well. So is it possible to set something in to prototype it uses locales from a different object name? My new objects are not distinguishable from the "base" object by nature. Or provide the English locale from the data.lua?
Re: Locale strings from data.lua
Could you specify what kind of mod you are making?
Making entities undistinguishable from ones already in game is usually pretty stupid...
You can make shortcuts, like the "mods" folder.
Making entities undistinguishable from ones already in game is usually pretty stupid...
You can make shortcuts, like the "mods" folder.
Re: Locale strings from data.lua
I'm working on an alien breeding mod. So I have many "variations" of the same alien with different "power levels". But let me be more clear on that area then, it doesn't matter if they all have the same name. As I'm planning on having sensors for the power levels and stuff. Would just be nice if we could prevent things like this:
https://github.com/MagmaMcFry/Factoriss ... ory-en.cfg
https://github.com/MagmaMcFry/Factoriss ... ory-en.cfg
Re: Locale strings from data.lua
Oh, i see...
I don't know if that's possible in Factorio or not, but in C++ (on which the game is based) you can do many entities from a prototype, with some values shared (max health, damage, etc.) and some other different for each entity (current health or your "power level").
Maybe you could just add another unshared value to the prototype?
I don't know if that's possible in Factorio or not, but in C++ (on which the game is based) you can do many entities from a prototype, with some values shared (max health, damage, etc.) and some other different for each entity (current health or your "power level").
Maybe you could just add another unshared value to the prototype?
Re: Locale strings from data.lua
in locale
in data when creating your prototype
Code: Select all
[entity-name]
my_entity_name=Entity Name
Code: Select all
name = my_entity_name_variant_32421433
localised_name = {"entity-name.my_entity_name"}
Re: Locale strings from data.lua
That seems to do the trick, thanks 

- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Locale strings from data.lua
I know it's not what you're looking for, but I've been doing extra fancy things such as
This will take take the locale item entry for that item, and add research to the end of it's name, and use that for the technology's same name.
Also take a look at base game's barrelling system, that takes the name of the fluid, and adds "barrel" to the end of it.
locale trickery!
Code: Select all
[technology-name]
low-density-structure=__ITEM__low-density-structure__ research
Also take a look at base game's barrelling system, that takes the name of the fluid, and adds "barrel" to the end of it.
locale trickery!
Re: Locale strings from data.lua
You can get even fancier and not even have to do a bunch of locale names for stuff like that
--this might work but havn't tested it
Code: Select all
[my-mod]
research=__1__ research
Code: Select all
my_prototype.localised_name = {"my-mod.research", data.raw["item"]["low-density-structure"].localised_name}
Code: Select all
my_prototype.localised_name = {"my-mod.research", {"__ITEM__low-density-structure__"}}
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Locale strings from data.lua
I think it would need to be:Nexela wrote:--this might work but havn't tested itCode: Select all
my_prototype.localised_name = {"my-mod.research", {"__ITEM__low-density-structure__"}}
Code: Select all
my_prototype.localised_name = {"my-mod.research", {"item-name.low-density-structure"}}
Re: Locale strings from data.lua
That seems to work indeed.
For reference:
locale.cfg
data.lua
(sex is M or F, level is A to Z and is not translated)
For reference:
locale.cfg
Code: Select all
[fm-alien]
name=__2__ __1__ (__3__)
egg-name=__2__ __1__ egg (__3__)
sex_M=Male
sex_F=Female
Code: Select all
localised_name = {"fm-alien.name", {"entity-name."..name}, {"fm-alien.sex_"..sex}, level},
...
localised_name = {"fm-alien.egg-name", {"entity-name."..name}, {"fm-alien.sex_"..sex}, level},