Canisters deprecated

by 0n0w1c

Introduces reusable canisters for rocket launches. What goes up must come down!

Content
4 months ago
2.0
120

i (Resolved) Dynamically add Canisters to Rocket Fuel recipes

5 months ago
(updated 5 months ago)

Hiya,

Been playing with canisters for a while now, and noticed that you recently updated the mod to support alternative recipes.
I've been using some mods that add alternate recipes and wanted to ensure they use canisters as well.
So I wrote a small code snippet (and made a personal mod that I don't plan on publishing) to dynamically add canisters to any item that outputs rocket-fuel.
It does use part of your current code for recycling and such. No idea if you want to add dynamic recipe allocation (because of balancing etc), but figured I'd share anyway.

local recycling = {}

if mods["quality"] then
    recycling = require("__quality__/prototypes/recycling") 
end

for _, recipe in pairs(data.raw["recipe"]) do
    if recipe.results then
        for _, result in pairs(recipe.results) do
            if result.name:match("rocket%-fuel") and not recipe.category:match("recycling") then
                local has_canister = false

                if recipe.ingredients then
                    for _, ingredient in pairs(recipe.ingredients) do
                        if ingredient.name:match("canister") then
                            has_canister = true
                        end
                    end
                end

                if not has_canister then
                    table.insert(recipe.ingredients, { type = "item", name = "canister", amount = 1 })

                    if mods["quality"] then 
                        recycling.generate_recycling_recipe(recipe)
                    end
                end
            end
        end
    end
end
5 months ago

This is a great suggestion and thank you very much for the contribution!

5 months ago

Version 0.0.12 has been uploaded. Please let me know if it works for those modded recipes.

5 months ago

Version 0.0.12 has been uploaded. Please let me know if it works for those modded recipes.

Much appreciated! Glad to know I could help :)

New response