[2.0] Localised name interfering with recycling recipe localisation

Place to get help with not working mods / modding interface.
PyroGamer666
Burner Inserter
Burner Inserter
Posts: 16
Joined: Fri Aug 28, 2020 5:37 am
Contact:

[2.0] Localised name interfering with recycling recipe localisation

Post by PyroGamer666 »

Code: Select all

if settings.startup["experimental-features"].value==true then
  for i,entity in ipairs(Aircraft_List) do
    local new_plane = table.deepcopy(data.raw["car"][entity])
    local old_name=new_plane.name
    new_plane.name = new_plane.name .. "-carbon-fiber"
    new_plane.weight=new_plane.weight/2
    --new_plane.weight=new_plane.weight/2
    new_plane.max_health=new_plane.max_health/2
    new_plane.minable = {mining_time = 1, result = new_plane.name}
    --new_plane.localised_name = {{"item-name.carbon-fiber"},{"item-name."..old_name}}
    new_plane.localised_name = {{"carbon-fiber-aircraft"},{"item-name."..old_name}}
    data:extend({new_plane})
  end
This code is part of my fork of the Aircraft mod with changes specific to Space Age. In this code, I am creating a carbon fiber variant of every existing aircraft with half the health and weight of standard aircraft. The trouble begins with giving it a localised name. The localised name is supposed to be "Carbon fiber {plane name}" in English. This localised name triggers a crash from an auto-generated recipe related to the recycler. If I could find the code that generates this recipe, I'm sure I could find the problem myself, but I can't. I'm not sure how to account for this recipe's localisation issues in my mod, because it appears to generate after my mod loads.
11-04-2024, 14-33-09.png
11-04-2024, 14-33-09.png (68.17 KiB) Viewed 220 times
Nor017
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun Nov 03, 2024 2:16 pm
Contact:

Re: [2.0] Localised name interfering with recycling recipe localisation

Post by Nor017 »

normally you dont need to do in that way,just ignore the localised name and do it in the locale folder
User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 419
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: [2.0] Localised name interfering with recycling recipe localisation

Post by Stringweasel »

PyroGamer666 wrote: Mon Nov 04, 2024 10:37 pm

Code: Select all

if settings.startup["experimental-features"].value==true then
  for i,entity in ipairs(Aircraft_List) do
    local new_plane = table.deepcopy(data.raw["car"][entity])
    local old_name=new_plane.name
    new_plane.name = new_plane.name .. "-carbon-fiber"
    new_plane.weight=new_plane.weight/2
    --new_plane.weight=new_plane.weight/2
    new_plane.max_health=new_plane.max_health/2
    new_plane.minable = {mining_time = 1, result = new_plane.name}
    --new_plane.localised_name = {{"item-name.carbon-fiber"},{"item-name."..old_name}}
    new_plane.localised_name = {{"carbon-fiber-aircraft"},{"item-name."..old_name}}
    data:extend({new_plane})
  end
This code is part of my fork of the Aircraft mod with changes specific to Space Age. In this code, I am creating a carbon fiber variant of every existing aircraft with half the health and weight of standard aircraft. The trouble begins with giving it a localised name. The localised name is supposed to be "Carbon fiber {plane name}" in English. This localised name triggers a crash from an auto-generated recipe related to the recycler. If I could find the code that generates this recipe, I'm sure I could find the problem myself, but I can't. I'm not sure how to account for this recipe's localisation issues in my mod, because it appears to generate after my mod loads.
11-04-2024, 14-33-09.png
This doesn't look like a valid localized string. And it could mean that it game just happens to crash on the new recipe first instead of on your prototypes.

Code: Select all

 new_plane.localised_name = {{"carbon-fiber-aircraft"},{"item-name."..old_name}}
What are you trying to concatenate? You can see here how to add localized strings together: https://wiki.factorio.com/Tutorial:Loca ... ed_strings

Or is it a parameter, like __1__? Then it might have to be this (notice the brackets)

Code: Select all

 new_plane.localised_name = {"carbon-fiber-aircraft.something", {"item-name."..old_name}}
Alt-F4 Author | Factorio Modder
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby
Official Contributor to Space Exploration
User avatar
BraveCaperCat
Filter Inserter
Filter Inserter
Posts: 380
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Re: [2.0] Localised name interfering with recycling recipe localisation

Post by BraveCaperCat »

__mod-name__/locale/en/mod.config:

Code: Select all

[plane-locale]
carbon=Carbon fiber __1__
__mod-name__/data.lua:

Code: Select all

if settings.startup["experimental-features"].value==true then
  for i,entity in ipairs(Aircraft_List) do
    local new_plane = table.deepcopy(data.raw["car"][entity])
    local old_name=new_plane.name
    new_plane.name = new_plane.name .. "-carbon-fiber"
    new_plane.weight=new_plane.weight/2
    --new_plane.weight=new_plane.weight/2
    new_plane.max_health=new_plane.max_health/2
    new_plane.minable = {mining_time = 1, result = new_plane.name}
    --new_plane.localised_name = {{"item-name.carbon-fiber"},{"item-name."..old_name}}
    new_plane.localised_name = {"plane-locale.carbon", " item-name." .. old_name}
    data:extend({new_plane})
  end
This should work.
If it doesn't, add this code to data-final-fixes.lua:

Code: Select all

log(serpent.block(data.raw["recipe"]["gunship-carbon-fiber-recycling"]))
Then post the log here.
Creator of multiple mods, including Quality Assurance - My most popular one.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Post Reply

Return to “Modding help”