From 4f7d78a87e13dfbdb571ec17e3f4a60ae7bcadc9 Mon Sep 17 00:00:00 2001 From: protocol_1903 <67478786+protocol-1903@users.noreply.github.com> Date: Mon, 31 Aug 2026 09:35:25 -0700 Subject: [PATCH] Changed py.add_to_description to use custom_tooltip_fields --- changelog.txt | 1 + data-final-fixes.lua | 2 +- lib/data-stage.lua | 47 +++++++++-------------------------------- locale/de/locale.cfg | 2 +- locale/en/locale.cfg | 2 +- locale/es-ES/locale.cfg | 2 +- locale/fr/locale.cfg | 2 +- locale/nl/locale.cfg | 2 +- locale/pl/locale.cfg | 2 +- locale/ru/locale.cfg | 2 +- locale/uk/locale.cfg | 2 +- 11 files changed, 20 insertions(+), 46 deletions(-) diff --git a/changelog.txt b/changelog.txt index ba3c41a..dcd2888 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Version: 3.1.4 Date: ???? Changes: + - Changed py.add_to_description to use custom_tooltip_fields - Fixed that recipes without a main product or without a localised name would not have recipe signals generated for them. Resolves https://github.com/pyanodon/pybugreports/issues/1494, resolves https://github.com/pyanodon/pybugreports/issues/1528 --------------------------------------------------------------------------------------------------- Version: 3.1.3 diff --git a/data-final-fixes.lua b/data-final-fixes.lua index 4d5a0b0..8c00773 100644 --- a/data-final-fixes.lua +++ b/data-final-fixes.lua @@ -320,7 +320,7 @@ end if mods.pycoalprocessing and not mods["extended-descriptions"] then for _, recipe in pairs(data.raw.recipe) do if recipe.allow_productivity then - py.add_to_description("recipe", recipe, {"recipe-description.affected-by-productivity"}) + py.add_to_description("recipe", recipe, nil, {"recipe-description.affected-by-productivity"}) end end end diff --git a/lib/data-stage.lua b/lib/data-stage.lua index 76df413..ad47bc5 100644 --- a/lib/data-stage.lua +++ b/lib/data-stage.lua @@ -49,44 +49,17 @@ py.generate_localised_description = function(base_name, tier) end ---Adds a localised string to the prototype's description. ----@param type string ---@param prototype data.AnyPrototype ----@param localised_string LocalisedString -py.add_to_description = function(type, prototype, localised_string) - --[[@cast localised_string string]] -- can also be a nested table but it hides warnings at least - if prototype.localised_description and prototype.localised_description ~= "" then - prototype.localised_description = {"", prototype.localised_description, "\n", localised_string} - return - end - - local place_result = prototype.place_result or prototype.place_as_equipment_result - if type == "item" and place_result then - for _, machine in pairs(data.raw) do - machine = machine[place_result] - if machine and machine.localised_description then - prototype.localised_description = { - "?", - {"", machine.localised_description, "\n", localised_string}, - localised_string - } - return - end - end - - local entity_type = prototype.place_result and "entity" or "equipment" - prototype.localised_description = { - "?", - {"", {entity_type .. "-description." .. 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 +---@param name? LocalisedString|string filled with an empty string if not added +---@param value LocalisedString|string +py.add_to_description = function(prototype, name, value) + ---@cast name LocalisedString? + ---@cast value LocalisedString? + prototype.custom_tooltip_fields = prototype.custom_tooltip_fields or {} + prototype.custom_tooltip_fields[#prototype.custom_tooltip_fields + 1] = { + name = name or "", + value = value + } end ---adds a glow layer to any item prototype. diff --git a/locale/de/locale.cfg b/locale/de/locale.cfg index 240aa7b..2e81a13 100644 --- a/locale/de/locale.cfg +++ b/locale/de/locale.cfg @@ -19,7 +19,7 @@ consistency-check-complete=Technologieüberprüfung abgeschlossen. Einen schöne yarm-remote-viewer=Charakter [recipe-description] -affected-by-productivity=[font=default-semibold][color=255,230,192]Beeinflusst durch Produktivität[/color][/font] +affected-by-productivity=Beeinflusst durch Produktivität [recipe-name] recipe-amount=(__1__ ×) __2__ diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index ad74603..5865dc2 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -25,7 +25,7 @@ update-note=[color=yellow]__1__ update note:[/color] __2__ yarm-remote-viewer=Character [recipe-description] -affected-by-productivity=[font=default-semibold][color=255,230,192]Affected by productivity[/color][/font] +affected-by-productivity=Affected by productivity [recipe-name] recipe-amount=(__1__ ×) __2__ diff --git a/locale/es-ES/locale.cfg b/locale/es-ES/locale.cfg index 3aebbd5..b317b82 100644 --- a/locale/es-ES/locale.cfg +++ b/locale/es-ES/locale.cfg @@ -27,7 +27,7 @@ update-note=[color=yellow]__1__ Notas de la actualización:[/color] __2__ yarm-remote-viewer=Personaje [recipe-description] -affected-by-productivity=[font=default-semibold][color=255,230,192]Afectado por la productividad[/color][/font] +affected-by-productivity=Afectado por la productividad [recipe-name] recipe-amount=(__1__ ×) __2__ diff --git a/locale/fr/locale.cfg b/locale/fr/locale.cfg index 174ed0b..c8cf48d 100644 --- a/locale/fr/locale.cfg +++ b/locale/fr/locale.cfg @@ -19,7 +19,7 @@ consistency-check-complete=Vérification de la technologie terminée, bonne jour yarm-remote-viewer=Personnage [recipe-description] -affected-by-productivity=[font=default-semibold][color=255,230,192]Affecté par la productivité[/color][/font] +affected-by-productivity=Affecté par la productivité [recipe-name] recipe-amount=(__1__ ×) __2__ diff --git a/locale/nl/locale.cfg b/locale/nl/locale.cfg index 12d6b03..d10b250 100644 --- a/locale/nl/locale.cfg +++ b/locale/nl/locale.cfg @@ -21,7 +21,7 @@ consistency-check-complete=Technologieverificatie klaar, fijne dag. yarm-remote-viewer=Karakter [recipe-description] -affected-by-productivity=[font=default-semibold][color=255,230,192]Beïnvloed door productiviteit[/color][/font] +affected-by-productivity=Beïnvloed door productiviteit [recipe-name] recipe-amount=(__1__ ×) __2__ diff --git a/locale/pl/locale.cfg b/locale/pl/locale.cfg index 0b76f57..38e5de8 100644 --- a/locale/pl/locale.cfg +++ b/locale/pl/locale.cfg @@ -25,7 +25,7 @@ update-note=[color=yellow]__1__ informacja o aktualizacji:[/color] __2__ yarm-remote-viewer=Postać [recipe-description] -affected-by-productivity=[font=default-semibold][color=255,230,192]Wpływ na produktywność[/color][/font] +affected-by-productivity=Wpływ na produktywność [recipe-name] recipe-amount=(__1__ ×) __2__ diff --git a/locale/ru/locale.cfg b/locale/ru/locale.cfg index ace3590..c95a2bf 100644 --- a/locale/ru/locale.cfg +++ b/locale/ru/locale.cfg @@ -28,7 +28,7 @@ yarm-remote-viewer=Персонаж recipe-amount=(__1__ ×) __2__ [recipe-description] -affected-by-productivity=[font=default-semibold][color=255,230,192]На рецепт влияет продуктивность[/color][/font] +affected-by-productivity=На рецепт влияет продуктивность [modifier-description] change-recipe-productivity=Продуктивность "__1__": __2__ diff --git a/locale/uk/locale.cfg b/locale/uk/locale.cfg index e6dc507..aa1b589 100644 --- a/locale/uk/locale.cfg +++ b/locale/uk/locale.cfg @@ -19,7 +19,7 @@ consistency-check-complete=Перевірку технології заверш yarm-remote-viewer=Персонаж [recipe-description] -affected-by-productivity=[font=default-semibold][color=255,230,192]Впливає на продуктивність[/color][/font] +affected-by-productivity=Впливає на продуктивність [recipe-name] recipe-amount=(__1__ ×) __2__