Automatically generating localized names

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 582
Joined: Tue May 19, 2015 1:56 am
Contact:

Automatically generating localized names

Post by Reika »

I have a research that adds turret range upgrades, but to do this it has to effectively clone turrets once per turret type, once per level.

This all works fine, but the problem is that the upgraded turrets (internally named [original name]-rangeboost-[level]") have no corresponding localization. As I cannot foresee all the possible turret types, nor am I willing to hardcode 800 entries for the ones I do know (Bob, 5Dim, DyTech, my Concussion, Plasma, and Cannon...), is there a way to either forcibly set a localized name (English only is fine, as it is still better than "unknown key:blah") or automatically populate the locale files? Ideally I would want the derivative turrets to appear exactly as their base counterparts.
Image

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

Re: Automatically generating localized names

Post by Nexela »

In locale.cfg

Code: Select all

[turrets]
upgrade=__1__ range_boost __2__
in data*.lua

Code: Select all

myturret.localised_name = {"turrets.upgrade", {"entity-name."..turret_name_from_loop}, level}

User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 582
Joined: Tue May 19, 2015 1:56 am
Contact:

Re: Automatically generating localized names

Post by Reika »

Nexela wrote:In locale.cfg

Code: Select all

[turrets]
upgrade=__1__ range_boost __2__
in data*.lua

Code: Select all

myturret.localised_name = {"turrets.upgrade", {"entity-name."..turret_name_from_loop}, level}
What will that parse into?
Image

User avatar
nucleargen
Long Handed Inserter
Long Handed Inserter
Posts: 64
Joined: Sat May 07, 2016 4:51 pm
Contact:

Re: Automatically generating localized names

Post by nucleargen »

%turret_name% range_boost %level%
%turret_name% = {"entity-name."..turret_name_from_loop} - entity name from your data loop.
__1__ and __2__ are placeholders.
The brightest future in the center of a nuclear explosion...2003©nucleargen

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

Re: Automatically generating localized names

Post by Nexela »

Code: Select all

myturret.localised_name =  -- Set the localized name for this prototype  
{ --in most places if something takes a string you can use {} brackets to tell it to look for an entry in the locale table
"turrets.upgrade", --use the localization "turrets.upgradge"
 {"entity-name."..turret_name_from_loop}, --use the localization for "entity-name.turrent-name"  as the first placeholder value
 level -- use the variable level for the third argument.
}

Post Reply

Return to “Modding help”