Localised descriptions, again

Place to get help with not working mods / modding interface.
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2529
Joined: Fri Nov 06, 2015 7:41 pm

Localised descriptions, again

Post by Deadlock989 »

Let me sing you the song of my people.

I know we've been down this path before, and I've searched, but it just feels like the parable of the blind men feeling various bits of an elephant and drawing dubious conclusions on the nature of elephants.

What I want to do: I am processing recipes. If a recipe meets a certain criterion, then I want to add a line to its localised description, if it has one; if it doesn't have one then I just set the line. Basically I want to provide extra info about that recipe but I don't want to obliterate useful info provided by vanilla or that I have personally painstakingly typed out myself into the locale config.

The problem is, finding out whether it "has" a description or not is a nightmare, because when the recipe description doesn't explicitly specify a description, it will inherit the item description if it has one, and if the item doesn't have one then it will inherit one from the entity. Even worse, neither recipe, item nor entity prototype have to set an explicit string: if a matching entry exists in whatever locale the player is using, it's displayed. So there seems to be no way of knowing what the player sees. It is Schrodinger's Description. You can make guesses based on whether the strings are set and whether the root item has a place result but you just don't know.

So I can either override the recipe description blindly, or I can make a best guess at what locale string is most relevant - recipe-description, item-description or entity-description - and embed it in a locale string like { "recipe-description.whatever", {"entity-description.whatever"}}. Sounds clever but actually, it fails about 75% of the time, because you get missing keys for the many vanilla items which have none of those three. So I can either document every vanilla item as well, or just give up.

Did anyone beat this yet?
Post Reply

Return to “Modding help”