Page 1 of 1
[2.0] Localised name interfering with recycling recipe localisation
Posted: Mon Nov 04, 2024 10:37 pm
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 (68.17 KiB) Viewed 222 times
Re: [2.0] Localised name interfering with recycling recipe localisation
Posted: Wed Nov 06, 2024 9:30 am
by Nor017
normally you dont need to do in that way,just ignore the localised name and do it in the locale folder
Re: [2.0] Localised name interfering with recycling recipe localisation
Posted: Wed Nov 06, 2024 9:39 am
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}}
Re: [2.0] Localised name interfering with recycling recipe localisation
Posted: Wed Nov 06, 2024 10:03 am
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.