Page 1 of 1

[Solved] Item localized desc with startup setting variable

Posted: Mon Oct 05, 2020 11:42 pm
by rookhaven
I'm trying to put a startup setting in as a variable in my item description. This works fine in the control stage, but I'm not getting it to work in the data stage. The settings tutorial page seems to indicate it can be done (as do other posts) but I be dumb. This is literally the first example from the wiki. Does this not work for localization settings at data stage? Settings is the first stage right?

From Wiki:

Code: Select all

--in settings.lua:
data:extend({
    {
        type = "int-setting",
        name = "my-mod-stone-wall-stack-size",
        setting_type = "startup",
        minimum_value = 1,
        default_value = 100
    }
})

--in data.lua:
data.raw.item["stone-wall"].stack_size = settings.startup["my-mod-stone-wall-stack-size"].value
I have the following in my locale.cfg (ellipsis mine):

Code: Select all

[item-description]
k2cp-city=...They can also only be placed within __1__ tiles of each...
The variable to populate the __1__ is a startup setting defined as follows. The setting works fine in the control stage - does what it's supposed to:
My settings.lua:

Code: Select all

data:extend({
 {
	type = "int-setting",
       	name = "k2cp-city-distance",
	setting_type = "startup",
	admin = true,
	default_value = 320,
	minimum_value = 32,
	order = "c"
},
I tried a couple things. In data.lua I have the following. I tried it in data-final-fixes.lua as well, but neither are working. The description just shows up with the __1__ in it. No errors are returned.
My data.lua:

Code: Select all

require("prototypes.entities")
require("prototypes.items")
require("prototypes.recipes")
require("prototypes.style")
require("prototypes.technology")

data.raw.item["k2cp-city"].localized_description = {"item-description.k2cp-city", settings.startup["k2cp-city-distance"].value}
Please advise and thank you.

Re: Item localized desc with startup setting variable

Posted: Wed Oct 07, 2020 5:50 pm
by Bilka
The --check-unused-prototype-data command line option shows:

3.480 Warning PrototypeLoader.cpp:202: Value ROOT.item.k2cp-city.localized_description[0] was not used.
3.480 Warning PrototypeLoader.cpp:202: Value ROOT.item.k2cp-city.localized_description[1] was not used.

It's "localised_description".

Re: Item localized desc with startup setting variable

Posted: Fri Oct 09, 2020 2:40 am
by rookhaven
Isn't that what this line is my data.lua is doing (see original code) - setting the localized_description for the item? I did try it in the item definition directly and in data-final-fixes, but it's still coming back with the __1__ showing instead of the setting value. The setting value must be coming back as null? Are my brackets correct?

Code: Select all

data.raw.item["k2cp-city"].localized_description = {"item-description.k2cp-city", settings.startup["k2cp-city-distance"].value}

Re: Item localized desc with startup setting variable

Posted: Fri Oct 09, 2020 9:34 am
by steinio
S instead of Z in localised

Re: Item localized desc with startup setting variable

Posted: Fri Oct 09, 2020 9:45 am
by ickputzdirwech
It’s probably not the first time this is mentioned but you have to be careful how you write certain words (just copy paste them to be sure) since the used dialect isn’t entirely consistent. For example “color” (American) and “localised” (British).

Re: Item localized desc with startup setting variable

Posted: Sat Oct 10, 2020 7:22 am
by rookhaven
Wow, I feel sheepish. The eyes certainly see what they want to see don't they.

Thanks all. Marking resolved.