Open shpaass opened 8 months ago
The ? stems from FactorioDataDeserializer line 568.
It arrives on line 565 with a luaTable containing a localised_descripption of 3 elements, an ?, and 2 other luaTable
Moving into the Localize(table)
function, it decides to call Localize("?", table)
that in turns calls FactorioLocalization.Localize("?")
that returns null
. Then on line 491 it calls table.ArrayElements
If i had to guess where this dataset comes from:
It seems pycoalprocessing_2.1.22\prototypes\functions\functions.lua:1302 adds a entity-description like this:
-- adds some text to a prototype's localised description
function overrides.add_to_description(type, prototype, localised_string)
if prototype.localised_description and prototype.localised_description ~= '' then
prototype.localised_description = {'', prototype.localised_description, '\n', localised_string}
else
if type == 'item' and prototype.place_result then
for _, machine in pairs(data.raw) do
machine = machine[prototype.place_result]
if machine and machine.localised_description then
prototype.localised_description = {
'?',
{'', machine.localised_description, '\n', localised_string},
localised_string
}
return
end
end
prototype.localised_description = {
'?',
{'', {'entity-description.' .. prototype.place_result}, '\n', localised_string},
{'', {type .. '-description.' .. prototype.name}, '\n', localised_string},
localised_string
}
else
prototype.localised_description = {'?', {'', {type .. '-description.' .. prototype.name}, '\n', localised_string}, localised_string}
end
end
end
After going trough all this code, i'm still clueless what's going on here lol.
that's a new feature introduced in 1.1.73, officially called "fallback group"
for more information see https://forums.factorio.com/viewtopic.php?f=3&t=104293 and https://forums.factorio.com/71553
Thank you for the info! Practically, do we want to hide this question mark, or do you have other ideas about how to handle it?
I was playing around to see if I could fix this. This snippet helps some cases e.g. Bonemeal (the item) is ? in main but with the following fix displays the right info. But it then causes items where there is no localisation (e.g. the diesel recipe) to show the localisation key: "recipe-description.diesel"
private void Localize(object obj)
{
if (obj is LuaTable table)
{
if (!table.Get(1, out string key))
return;
if (key == "?")
Localize(table[2]);
else
Localize(key, table);
}
else localeBuilder.Append(obj);
}
What's the actual desired behaviour if a localisation is missing?
If we follow what Factorio seems to do, it'd simply fail the first localisation lookup and return empty string for that specific item. In this specific case ("recipe-description.diesel") that would mean there's no description for the recipe and the next part of the localisation occurs (the "affected by productivity" string is put in the description).
https://github.com/have-fun-was-taken/yafc-ce/pull/63 might be useful as a starting point for fixing this properly.
What's the actual desired behaviour if a localisation is missing?
I think it's either to show nothing or the key. There are arguments for both of the approaches, so it's up to you.
Wouldn't you default to english then? If that's also missing i guess the above.
Wouldn't you default to english then?
From what I see, YAFC already uses English everywhere, no matter what language your system or the game is using.
Not for me, it has the same parts dutch as Factorio has ingame.
The in-game items are localized (by the mods), but the whole application itself uses (hard-coded) English. Open some files and you see all kind of strings in the code to be rendered in the UI. (Unles SDL applies some magic to match them against localisation files to translate?)
Here are the before and after for what's currently implemented in https://github.com/have-fun-was-taken/yafc-ce/pull/63 It tries to match what's what Factorio does as closely as possible.
Before:
After:
When choosing a production recipe, when hovering over some recipes, the first line sometimes is
?
instead ofA recipe to create something
:It would be useful to understand why exactly the question mark is shown because it is shown quite often, and it can bring confusion to the end user.
A mod-list to replicate the exact same situation would be quite large, but the bulk of the mods is Pyanodons Alternative Energy and all its mandatory dependencies.