Page 1 of 1

Locale strings from data.lua

Posted: Sun May 21, 2017 3:41 pm
by Daid
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?

Re: Locale strings from data.lua

Posted: Sun May 21, 2017 3:52 pm
by Sigor
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.

Re: Locale strings from data.lua

Posted: Sun May 21, 2017 7:16 pm
by Daid
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

Re: Locale strings from data.lua

Posted: Sun May 21, 2017 7:47 pm
by Sigor
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?

Re: Locale strings from data.lua

Posted: Sun May 21, 2017 10:29 pm
by Nexela
in locale

Code: Select all

[entity-name]
my_entity_name=Entity Name
in data when creating your prototype

Code: Select all

name = my_entity_name_variant_32421433
localised_name = {"entity-name.my_entity_name"}

Re: Locale strings from data.lua

Posted: Mon May 22, 2017 5:58 am
by Daid
That seems to do the trick, thanks :-)

Re: Locale strings from data.lua

Posted: Mon May 22, 2017 8:11 am
by bobingabout
I know it's not what you're looking for, but I've been doing extra fancy things such as

Code: Select all

[technology-name]
low-density-structure=__ITEM__low-density-structure__ research
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!

Re: Locale strings from data.lua

Posted: Mon May 22, 2017 10:44 am
by Nexela
You can get even fancier and not even have to do a bunch of locale names for stuff like that

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}
--this might work but havn't tested it

Code: Select all

my_prototype.localised_name = {"my-mod.research", {"__ITEM__low-density-structure__"}}

Re: Locale strings from data.lua

Posted: Mon May 22, 2017 11:51 am
by bobingabout
Nexela wrote:--this might work but havn't tested it

Code: Select all

my_prototype.localised_name = {"my-mod.research", {"__ITEM__low-density-structure__"}}
I think it would need to be:

Code: Select all

my_prototype.localised_name = {"my-mod.research", {"item-name.low-density-structure"}}

Re: Locale strings from data.lua

Posted: Wed May 24, 2017 9:41 pm
by Daid
That seems to work indeed.

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
data.lua

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},
(sex is M or F, level is A to Z and is not translated)