[0.14] Modding - glitch in item localisation

Bugs that are actually features.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

[0.14] Modding - glitch in item localisation

Post by aubergine18 »

If I define an item X, which when placed creates entity X, and set locale keys for both the item and the entity...

Code: Select all

[item-name]
X = X item name

[item-description]
X = X item description

[entity-name]
X = X entity name

[entity-description]
X = X entity description
When I hover over the recipe, I see: "X entity name" and "X item description" (I expect "X item name" and "X item description")

When I hover over the item in an inventory or quickbar, I see "X entity name" and "X item description" (I expect "X item name" and "X item description")

If I drop the item on map, when I hover over its item-entity (item-on-ground), I see: "X entity name" and no description (I expect "X item name" and "X item description")

While placing the entity on map, I see "X entity name" and "X entity description" (this is correct)

When hovering placed entity, I see "X entity name" and "X entity description" (this is correct)

Other notes which may or may not be relevant:

1. I tried setting `[recipe-name] X = recipe name` (obvs. with a line feed in there) in locale file - did not have any effect. (I would expect recipe name/description to override item name/description in crafting menu)

2. I tried setting, in the item prototype, `locale_name = { "item-name.X" }` - did not have any effect. (I would expect setting locale_name/locale_description) on any prototype to override the respective locale keys for that prototype, thus allowing re-use of existing translations)

It seems that items default to the name of the entity they create when placed (`place_result`), even if the name of the item is defined. Yet they correctly use item description in preference to entity description.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15913
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by Rseding91 »

Item-name is only used if you define the localized_name directly in the prototype or the item has no place result (entity, equipment, or tile).

That's by design since locale keys can't be conditionally used in prototypes. That was the cause of desyncs previously and the above change was the fix.
If you want to get ahold of me I'm almost always on Discord.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by aubergine18 »

Is the same not true of the description, as that seems to work conditionally? (the item-description is shown in crafting screen for example).
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15913
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by Rseding91 »

aubergine18 wrote:Is the same not true of the description, as that seems to work conditionally? (the item-description is shown in crafting screen for example).
item description is always item description. It doesn't show anything else. If the item doesn't have a description none is shown.

When I say "conditionally" I refer to "should it use the item-name locale or the first entity it builds or the first tile it builds or ..." instead of "just use item-name even if it probably doesn't have a locale entry".
If you want to get ahold of me I'm almost always on Discord.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by aubergine18 »

Would it be possible to add `locale_name` property in `item` prototype to set specific locale key to use for item name? This would be static as part of the item definition, so shouldn't cause desync?
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15913
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by Rseding91 »

aubergine18 wrote:Would it be possible to add `locale_name` property in `item` prototype to set specific locale key to use for item name? This would be static as part of the item definition, so shouldn't cause desync?
That's already a thing: localized_name and localized_description.
If you want to get ahold of me I'm almost always on Discord.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by aubergine18 »

Tried them as stated in OP - they didn't seem to work, but will test again.

EDIT: Tested in the item prototype, hoping it would set name based on key `item-name.wood-bridge` but it still showed the text for `entity-name.wood-bridge`:

Code: Select all

-- data.raw.item["wood-bridge"] value:

{
  default_request_amount = 4,
  flags = {
    "goes-to-quickbar",
    "goes-to-main-inventory"
  },
  icon = "__Epoch__/graphics/icon/wood-bridge.png",
  icon_size = 32,
  locale_name = {
    "item-name.wood-bridge-from"
  },
  name = "wood-bridge-from",
  order = "b[concrete]-c[wood-bridge]",
  place_result = "wood-bridge-from",
  stack_size = 4,
  subgroup = "terrain",
  type = "item"
}
Last edited by aubergine18 on Sun Oct 09, 2016 8:58 pm, edited 1 time in total.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15913
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by Rseding91 »

aubergine18 wrote:Tried them as stated in OP - they didn't seem to work, but will test again.
Look at how the base game uses them for some of the technology prototypes.
If you want to get ahold of me I'm almost always on Discord.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by aubergine18 »

Posted test results above - didn't work for item prototype.

EDIT: Doh! Just seen what I did wrong - spelling typo. Will try again.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by aubergine18 »

Ok, retested - still no joy:

Code: Select all

-- item definition

{
  default_request_amount = 4,
  flags = {
    "goes-to-quickbar",
    "goes-to-main-inventory"
  },
  icon = "__Epoch__/graphics/icon/wood-bridge.png",
  icon_size = 32,
  localized_name = {
    "item-name.wood-bridge-from"
  },
  name = "wood-bridge-from",
  order = "b[concrete]-c[wood-bridge]",
  place_result = "wood-bridge-from",
  stack_size = 4,
  subgroup = "terrain",
  type = "item"
}
And the locale strings:

Code: Select all

[recipe-name]
wood-bridge-from = Wooden Bridge

[item-name]
wood-bridge-from = Wooden Bridge

[item-description]
wood-bridge-from = Rickety wooden pedestrian bridge for crossing water.

[entity-name]
wood-bridge-from = Wood Bridge: Set start point
wood-bridge-to   = Wood Bridge: Set end point

[entity-description]
wood-bridge-from = Place at waters' edge to start building the wooden bridge.
wood-bridge-to   = Place on the opposite shore to complete the wooden bridge.
wood-bridge-cap  = Rickety pedestrian bridge.\n\nIt can be removed by mining or destroying this end cap.
Result in game (crafting screen):

Image

It's still showing `entity-name.wood-bridge-from`, despite me having `localized_name = { "item-name.wood-bridge-from" }`.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15913
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by Rseding91 »

You're looking at the recipe name ... not the item name.

Set the locale name in the recipe prototype.
If you want to get ahold of me I'm almost always on Discord.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by aubergine18 »

I put the locaized_name in to both the item proto and the recipe proto. Neither had any effect either on the crafting screen or items when in quickbar etc.

Recipe proto (trimmed for brevity):

Code: Select all

{
  enabled = true,
  ingredients = {
--trimmed
  },
  localized_name = {
    "recipe-name.wood-bridge-from"
  },
  name = "wood-bridge",
  results = {
    {
      amount = 1,
      amount_max = 1,
      amount_min = 1,
      name = "wood-bridge-from",
      probability = 1,
      type = "item"
    }
  },
  type = "recipe"
}
Doesn't seem to work:

Image

Item proto:

Code: Select all

{
  default_request_amount = 4,
  flags = {
    "goes-to-quickbar",
    "goes-to-main-inventory"
  },
  icon = "__Epoch__/graphics/icon/wood-bridge.png",
  icon_size = 32,
  localized_name = {
    "item-name.wood-bridge-from"
  },
  name = "wood-bridge-from",
  order = "b[concrete]-c[wood-bridge]",
  place_result = "wood-bridge-from",
  stack_size = 4,
  subgroup = "terrain",
  type = "item"
}
Doesn't seem to work

Image
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15913
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by Rseding91 »

Yes it does:

Image

You must be doing some part of it wrong.
If you want to get ahold of me I'm almost always on Discord.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [0.14] Modding - glitch in item localisation

Post by aubergine18 »

ah, I had typo based on what you posted earlier: localized - should be localised (s not z). it's days like this I wish I wasn't partially dyslexic :/

Checking...

Yes, it works! For both item and recipe! :D

Thank you for your patience!
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Post Reply

Return to “Not a bug”