[Space Age] Recipes with no category have no recycling recipes

Bugs that are actually features.
User avatar
BraveCaperCat
Filter Inserter
Filter Inserter
Posts: 313
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

[Space Age] Recipes with no category have no recycling recipes

Post by BraveCaperCat »

As mentioned in the (long) subject, recipes with no category property don't have recycling recipes. You can test this with my mod Quality Assurance (where every new recipe doesn't have a category). I will fix this in Quality Assurance, so make sure you have the current version as of posting, 1.2.3.

As seen in this image, placing an AMS machine into a recycler (image taken with just QA, Quality and the Base Mod) shows an unlocalised message saying that the machine can't be recycled.
Unknown key: "inventory-restriction.cant-be-recycled"
Unknown key: "inventory-restriction.cant-be-recycled"
Screenshot 2024-11-23 142837.png (1.83 MiB) Viewed 285 times
Please fix this issue, as the category property is OPTIONAL, and the code to create the AMS machines doesn't opt-out of recycling, or use a category banned from recycling such as chemistry or crafting-with-fluid.
Here is the relevant part of the code, where Machine is the entity the mod is making an AMS version of.

Code: Select all


                AMSMachineRecipe = {}
                AMSMachineRecipe.name = AMSMachineItem.name
                AMSMachineRecipe.type = "recipe"
                if Machine.localised_name ~= nil and not Machine.localised_name == {} and not Machine.localised_name == "" then
                    AMSMachineRecipe.localised_name = {"?", {"ams.name", {"?", {"__ENTITY__" .. Machine.name .. "__"}, Machine.localised_name}}, "ams.fallback-name"}
                else
                    AMSMachineRecipe.localised_name = {"?", {"ams.name", {"__ENTITY__" .. Machine.name .. "__"}}, {"ams.fallback-name"}}
                end
                if Machine.localised_description ~= nil and not Machine.localised_description == {} and not Machine.localised_description == "" then
                    AMSMachineRecipe.localised_description = {"?", {"ams.description", {"?", {"__ENTITY__" .. Machine.name .. "__"}, Machine.localised_description}}, "ams.fallback-description"}
                else
                    AMSMachineRecipe.localised_description = {"?", {"ams.description", {"__ENTITY__" .. Machine.name .. "__"}}, {"ams.fallback-description"}}
                end
                if Machine.MachineItem == nil and Machine.minable ~= nil then
                    if Machine.minable.result ~= nil and Machine.minable.result ~= "" then
                        AMSMachineRecipe.ingredients = {{type = "item", name = Machine.minable.result, amount = 1}, {type = "item", name = "steel-plate", amount = 10}, {type = "item", name = "copper-cable", amount = 20}}
                    else
                        AMSMachineRecipe.ingredients = {{type = "item", name = "electronic-circuit", amount = 1}, {type = "item", name = "steel-plate", amount = 10}, {type = "item", name = "copper-cable", amount = 20}}
                    end
                else
                    AMSMachineRecipe.ingredients = {{type = "item", name = Machine.MachineItem, amount = 1}, {type = "item", name = "steel-plate", amount = 10}, {type = "item", name = "copper-cable", amount = 20}}
                end

                if AMSMachineRecipe.ingredients[1]["name"] == nil then
                    AMSMachineRecipe.ingredients[1]["name"] = "electronic-circuit"
                    log("Had to replace ingredient name for \"" .. AMSMachineRecipe.name .. "\"")
                end

                AMSMachineRecipe.results = {{type = "item", name = AMSMachineItem.name, amount = 1}}
                AMSMachineRecipe.enabled = false
This recipe is later added to data.raw here, near the end of the code:

Code: Select all

                log("Made AMS version of \"" .. Machine.name .. "\".")
                data:extend{AMSMachine, AMSMachineItem, AMSMachineRecipe, AMSMachineTechnology}
with AMSMachine being an entity, AMSMachineItem being an item, AMSMachineRecipe being a recipe and AMSMachineTechnology being a technology.
Creator of multiple mods, including Quality Assurance - My most popular one. Expect multiple modding-related questions, answers and other posts.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3071
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [Space Age] Recipes with no category have no recycling recipes

Post by boskid »

Throwing this to Not a bug.

This mod adds new prototypes past the `data` stage, and past the `data-updates` of quality where the recycling recipes are generated. There are no recycling recipes because by the time quality mod was generating recycling recipes, those machines were not yet defined.

Code: Select all

   0.413 Loading mod core 0.0.0 (data.lua)
   0.426 Loading mod base 2.0.22 (data.lua)
   0.524 Loading mod quality 2.0.22 (data.lua)
   0.532 Loading mod base 2.0.22 (data-updates.lua)
   0.536 Loading mod quality 2.0.22 (data-updates.lua)
   0.543 Loading mod QualityAssurance 1.2.3 (data-updates.lua)
User avatar
BraveCaperCat
Filter Inserter
Filter Inserter
Posts: 313
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Re: [Space Age] Recipes with no category have no recycling recipes

Post by BraveCaperCat »

boskid wrote: Sat Nov 23, 2024 2:58 pm Throwing this to Not a bug.

This mod adds new prototypes past the `data` stage, and past the `data-updates` of quality where the recycling recipes are generated. There are no recycling recipes because by the time quality mod was generating recycling recipes, those machines were not yet defined.

Code: Select all

   0.413 Loading mod core 0.0.0 (data.lua)
   0.426 Loading mod base 2.0.22 (data.lua)
   0.524 Loading mod quality 2.0.22 (data.lua)
   0.532 Loading mod base 2.0.22 (data-updates.lua)
   0.536 Loading mod quality 2.0.22 (data-updates.lua)
   0.543 Loading mod QualityAssurance 1.2.3 (data-updates.lua)
How could I miss this...
I deliberately moved the data stage code from data.lua to data-updates.lua due to not having every crafting category available in certain AMS machines.
I'll try and work out another solution to the above problem, which caused this issue to be apparent. Note that the inventory description has no locale, you may want to fix that.
Creator of multiple mods, including Quality Assurance - My most popular one. Expect multiple modding-related questions, answers and other posts.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3071
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [Space Age] Recipes with no category have no recycling recipes

Post by boskid »

It looks like locale is present, but it was placed inside of `space-age` locales and as such is not available when playing without space-age...
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 305
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: [Space Age] Recipes with no category have no recycling recipes

Post by IsaacOscar »

You could try using this code on all your new prototypes: https://github.com/wube/factorio-data/b ... pdates.lua
Post Reply

Return to “Not a bug”