Locale strings from data.lua

Place to get help with not working mods / modding interface.
Post Reply
Daid
Fast Inserter
Fast Inserter
Posts: 163
Joined: Sun Jul 03, 2016 7:42 am
Contact:

Locale strings from data.lua

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

Sigor
Burner Inserter
Burner Inserter
Posts: 19
Joined: Sun Nov 20, 2016 5:07 pm
Contact:

Re: Locale strings from data.lua

Post 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.

Daid
Fast Inserter
Fast Inserter
Posts: 163
Joined: Sun Jul 03, 2016 7:42 am
Contact:

Re: Locale strings from data.lua

Post 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

Sigor
Burner Inserter
Burner Inserter
Posts: 19
Joined: Sun Nov 20, 2016 5:07 pm
Contact:

Re: Locale strings from data.lua

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

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Locale strings from data.lua

Post 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"}

Daid
Fast Inserter
Fast Inserter
Posts: 163
Joined: Sun Jul 03, 2016 7:42 am
Contact:

Re: Locale strings from data.lua

Post by Daid »

That seems to do the trick, thanks :-)

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Locale strings from data.lua

Post 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!
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Locale strings from data.lua

Post 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__"}}

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Locale strings from data.lua

Post 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"}}
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Daid
Fast Inserter
Fast Inserter
Posts: 163
Joined: Sun Jul 03, 2016 7:42 am
Contact:

Re: Locale strings from data.lua

Post 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)

Post Reply

Return to “Modding help”