Page 1 of 1

[0.15.34] LuaItemPrototype.localised_description no fallback

Posted: Sun Sep 24, 2017 11:48 am
by BluePsyduck
I encountered some odd behavior when accessing the localised values of the item_prototypes within a mod, but I am not sure if this is actually a bug.

The localised_name of the items seem to fall back to the entity names, if the item is placeable as entity. But the localised_description does not fall back to the entity description.

Example using the rocket silo:

Code: Select all

# control.lua
script.on_init(function()
    for _, item in pairs(game.item_prototypes) do
        if (item.name == 'rocket-silo') then
            print('NAME: ' .. item.localised_name[1])
            print('DESCRIPTION: ' .. item.localised_description[1])
            assert(false)
        end
    end
    assert(false)
end)
log wrote:NAME: entity-name.rocket-silo
DESCRIPTION: item-description.rocket-silo
Here you see that the rocket-silo tiem has the localised name "entity-name.rocket-silo" (i.e. it fell back to the entity), but it still holds on to "item-description.rocket-silo" (which does not exist) rather than also falling back to "entity-description.rocket-silo" (which actually exists).

Intended behavior or actual bug?

Re: [0.15.34] LuaItemPrototype.localised_description no fallback

Posted: Sun Sep 24, 2017 1:43 pm
by Rseding91
That's currently intended although there's no reason for it to work one way or the other. If someone has a good reason to make it work one way or the other I can change it but I've never seen anyone complain before.

Re: [0.15.34] LuaItemPrototype.localised_description no fallback

Posted: Sun Sep 24, 2017 3:07 pm
by BluePsyduck
The only reason I can give to change it is consistency: Why is the name of the entity used, but not the description? For me it would be more logical if either both values are taken from the entity, or none.