[2.0.24] Passing parameter into __ENTITY__ LocalisedString doesn't work

Things that has been reported already before.
Xorimuth
Filter Inserter
Filter Inserter
Posts: 730
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

[2.0.24] Passing parameter into __ENTITY__ LocalisedString doesn't work

Post by Xorimuth »

In 1.1 I had the following:

Code: Select all

[mod-setting-name]
power-overload-entity=__ENTITY____1____

Code: Select all

    local pole_name = "big-electric-pole"
    data:extend{
      {
        type = "string-setting",
        name = "power-overload-max-power-" .. pole_name,
        localised_name = {"mod-setting-name.power-overload-entity", pole_name},

        setting_type = "startup",
        default_value = "100MW",
      }
    }
In 2.0, it just displays as the following, which is not correct:
Screenshot 2024-12-10 at 00.32.34.png
Screenshot 2024-12-10 at 00.32.34.png (6.14 KiB) Viewed 540 times
It should display as "Big electric pole".

Obviously this is a simplified case, in reality I have a whole list of pole_names which I want to create settings for, which is why the `__ENTITY__` thing is very helpful... if I was able to pass parameters into it.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
User avatar
EvilPLa
Inserter
Inserter
Posts: 35
Joined: Sat Nov 14, 2020 7:26 am
Contact:

Re: [2.0.24] Passing parameter into __ENTITY__ LocalisedString doesn't work

Post by EvilPLa »

The same happens with __CONTROL__

in 1.1 I had "registered=Train [train=__1__] registered to __CONTROL____2____"
But in 2.0 that doesn't work anymore
12-11-2024, 13-49-04.png
12-11-2024, 13-49-04.png (77.01 KiB) Viewed 500 times
Wise men speak because they have something to say Fools because they have to say something. (Plato)
robot256
Smart Inserter
Smart Inserter
Posts: 1224
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [2.0.24] Passing parameter into __ENTITY__ LocalisedString doesn't work

Post by robot256 »

It looks like the string of four underscores is being escaped into two literal underscores. What if you put eight underscores on either side of the number?
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Genhis
Factorio Staff
Factorio Staff
Posts: 847
Joined: Wed Dec 24, 2014 8:19 am
Contact:

Re: [2.0.24] Passing parameter into __ENTITY__ LocalisedString doesn't work

Post by Genhis »

Thanks for the report, this is a duplicate of 117194.
Xorimuth
Filter Inserter
Filter Inserter
Posts: 730
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: [2.0.24] Passing parameter into __ENTITY__ LocalisedString doesn't work

Post by Xorimuth »

Genhis wrote: Wed Dec 11, 2024 2:15 pm Thanks for the report, this is a duplicate of 117194.
Thanks for the quick response, although that's unfortunate.
Sure I can do

Code: Select all

for _, pole_name in pairs(pole_names) do
    data:extend{
      {
        type = "string-setting",
        name = "power-overload-max-power-" .. pole_name,
        localised_name = {"entity-name." .. pole_name},
        setting_type = "startup",
        default_value = "100MW",
      }
    }
end
but this won't work if a mod has set the pole's name using `localised_name` - that is now impossible to access from setting names/descriptions.

Ah well, hopefully that won't be too common, and since `pole_names` is a manually curated list anyway (including many modded poles), I can always add in a hardcoded override for mods/poles that break with the above system. Or just let the locale errors persist.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Post Reply

Return to “Duplicates”