Page 1 of 1

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

Posted: Sat Nov 23, 2024 2:36 pm
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 292 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.

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

Posted: Sat Nov 23, 2024 2:58 pm
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)

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

Posted: Sat Nov 23, 2024 3:06 pm
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.

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

Posted: Sat Nov 23, 2024 6:40 pm
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...

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

Posted: Wed Nov 27, 2024 12:32 pm
by IsaacOscar
You could try using this code on all your new prototypes: https://github.com/wube/factorio-data/b ... pdates.lua