Page 1 of 1

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

Posted: Tue Dec 10, 2024 12:34 am
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 239 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.

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

Posted: Wed Dec 11, 2024 12:49 pm
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 199 times

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

Posted: Wed Dec 11, 2024 1:09 pm
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?

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

Posted: Wed Dec 11, 2024 2:15 pm
by Genhis
Thanks for the report, this is a duplicate of 117194.

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

Posted: Wed Dec 11, 2024 2:47 pm
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.