Skip to content

Instantly share code, notes, and snippets.

@shun-shobon
Last active March 17, 2022 02:46
Show Gist options
  • Save shun-shobon/aa7722f345d871ce667d7994b9325fe1 to your computer and use it in GitHub Desktop.
Save shun-shobon/aa7722f345d871ce667d7994b9325fe1 to your computer and use it in GitHub Desktop.
Interactions Recipe Calculator
local recipes = require("recipes")
local function calc_materials(name, amount, surpluses)
local target = recipes[name]
if target == nil then
return { [name] = amount }
end
local surplus = surpluses[name] or 0
local crafting = math.ceil((amount - surplus) / target.amount)
surpluses[name] = amount - target.amount * crafting
local materials = {}
for name, amount in pairs(target.recipe) do
for name, amount in pairs(calc_materials(name, amount * crafting, surpluses)) do
materials[name] = (materials[name] or 0) + amount
end
end
return materials
end
local function main()
io.write("Enter the artifact name: ")
local name = io.read()
io.write("Enter the artifact amount: ")
local amount = io.read("n")
local materials = calc_materials(name, amount, {})
for name, amount in pairs(materials) do
print(name, amount)
end
end
main()
local recipes = {
["Infinity Chicken"] = {
amount = 1,
recipe = {
["Awakened Draconium Block"] = 20,
["Crystal Matrix"] = 16,
["Crystal Cluster"] = 16,
["Stemcells"] = 8,
["Neutronium Block"] = 8,
["Corrupted Glitch Heart"] = 8,
["Infinity Block"] = 4,
["Chaos Shard"] = 1,
["Primal Mana"] = 100000,
["Lubricant"] = 250,
},
},
["Infinity Block"] = {
amount = 1,
recipe = {
["Infinity Ingot"] = 9,
},
},
["Infinity Ingot"] = {
amount = 4,
recipe = {
["Awakened Draconium Ingot"] = 4,
["Infinity Catalyst"] = 1,
["Argon"] = 500,
},
},
["Infinity Catalyst"] = {
amount = 1,
recipe = {
["Neutronium Ingot"] = 1,
["Neutronium Block"] = 2,
["Flux Block"] = 2,
["Block of Silicone Rubber"] = 4,
["Empowered Diamatine Crystal Block"] = 4,
["Hardened Enderium Glass"] = 2,
["Advanced Alchemical Construct"] = 1,
},
},
["Neutronium Block"] = {
amount = 1,
recipe = {
["Neutronium Ingot"] = 9,
},
},
["Flux Block"] = {
amount = 1,
recipe = {
["Flux"] = 5,
["Flux Core"] = 4,
},
},
["Flux Core"] = {
amount = 4,
recipe = {
["Flux"] = 4,
["Skystone Plate"] = 4,
["Improved Ender Eye"] = 1,
["Destabilized Redstone"] = 1296,
},
},
["Flux"] = {
amount = 16,
recipe = {
["Infinity Dust"] = 4,
["Flux Crystal"] = 1,
["Platinum Dust"] = 1,
["Liquid Antimatter"] = 1000,
}
},
["Flux Crystal"] = {
amount = 1,
recipe = {
["Mana Diamond"] = 1,
["Destabilized Redstone"] = 1000,
},
},
["Destabilized Redstone"] = {
amount = 144,
recipe = {
["Redstone"] = 1,
},
},
["Mana Diamond"] = {
amount = 1,
recipe = {
["Diamond"] = 1,
["Unstable Mana"] = 250,
},
},
["Block of Silicone Rubber"] = {
amount = 1,
recipe = {
["Silicone Rubber"] = 1296,
}
},
["Silicone Rubber"] = {
amount = 1296,
recipe = {
["Polydimethylsiloxane Dust"] = 9,
["Sulfur Dust"] = 1,
},
},
["Empowered Diamatine Crystal Block"] = {
amount = 1,
recipe = {
["Empowered Diamatine Crystal"] = 9,
},
},
["Empowered Diamatine Crystal"] = {
amount = 1,
recipe = {
["Diamatine Crystal"] = 1,
["Flawless Diamond"] = 1,
["Mana Pearl"] = 1,
}
},
["Mana Pearl"] = {
amount = 1,
recipe = {
["Eye of Ender"] = 1,
["Unstable Mana"] = 500,
},
},
["Hardened Enderium Glass"] = {
amount = 1,
recipe = {
["Enderium Ingot"] = 1,
["Hardened Glass"] = 1,
},
},
["Hardened Glass"] = {
amount = 1,
recipe = {
["Lead Dust"] = 2,
["Obsidian"] = 1,
},
},
["Advanced Alchemical Construct"] = {
amount = 1,
recipe = {
["Iron Plate"] = 4,
["Essentia Valve"] = 2,
["Essentia Tube"] = 2,
["Void Metal Plate"] = 2,
["Greatwood Planks"] = 1,
["Primordial Pearl"] = 1,
["Unstable Mana"] = 3000,
},
},
["Void Metal Plate"] = {
amount = 1,
recipe = {
["Void Metal Ingot"] = 1,
}
},
["Void Metal Ingot"] = {
amount = 1,
recipe = {
["Destructive Will Crystal"] = 4,
["Void Seed"] = 1,
["Liquid Nightmares"] = 4000,
},
},
["Void Seed"] = {
amount = 4,
recipe = {
["Thaumium Ingot"] = 1,
["Block of Black Quartz"] = 1,
["Wither Ash"] = 1,
["Vitium Vis Crystal"] = 1,
},
},
["Block of Black Quartz"] = {
amount = 1,
recipe = {
["Black Quartz"] = 4,
},
},
["Awakened Draconium Ingot"] = {
amount = 9,
recipe = {
["Awakened Draconium Block"] = 1,
},
},
["Awakened Draconium Block"] = {
amount = 1,
recipe = {
["Charged Draconium Block"] = 1,
["Dragon Heart"] = 1,
["Neutronium Ingot"] = 2,
["Crystal Matrix Ingot"] = 2,
["Dragonstone"] = 1,
}
},
["Charged Draconium Block"] = {
amount = 1,
recipe = {
["Draconium Block"] = 1,
["Flux"] = 4,
["Liquid Starlight"] = 50000,
},
},
["Draconium Block"] = {
amount = 1,
recipe = {
["Draconium"] = 1296,
},
},
["Draconium"] = {
amount = 16,
recipe = {
["Liquid Red Matter"] = 8,
["Osmiridium"] = 8,
},
},
["Liquid Red Matter"] = {
amount = 144,
recipe = {
["Red Matter"] = 1,
["Argon"] = 250,
},
},
["Red Matter"] = {
amount = 1,
recipe = {
["Dark Matter"] = 4,
["Void Metal Ingot"] = 1,
["Life Essence"] = 10000,
},
},
["Dark Matter"] = {
amount = 4,
recipe = {
["Vanadium Ingot"] = 4,
["Empowered Void Crystal"] = 1,
["Primal Mana"] = 2000,
},
},
["Empowered Void Crystal"] = {
amount = 1,
recipe = {
["Void Crystal"] = 1,
["Flawless Coal"] = 1,
["Mana Pearl"] = 1,
}
},
["Primal Mana"] = {
amount = 1000,
recipe = {
["Mana Dust"] = 1,
["Vinteum Dust"] = 1,
["Deuterium"] = 120,
},
},
["Mana Dust"] = {
amount = 1,
recipe = {
["Unstable Mana"] = 100000,
["Pyrotheum Dust"] = 1,
["Cryotheum Dust"] = 1,
["Aerotheum Dust"] = 1,
["Petrotheum Dust"] = 1,
},
},
["Crystal Matrix"] = {
amount = 1,
recipe = {
["Crystal Matrix Ingot"] = 9,
},
},
["Crystal Matrix Ingot"] = {
amount = 1,
recipe = {
["Diamond Lattice"] = 2,
["Nether Star"] = 1,
["Liquid Starlight"] = 10000,
},
},
["Diamond Lattice"] = {
amount = 1,
recipe = {
["Infused Diamond"] = 1,
["Diamond Plate"] = 4,
["Star Metal Screw"] = 4,
}
},
["Infused Diamond"] = {
amount = 1,
recipe = {
["Dimensional Shard"] = 8,
["Diamond"] = 1,
["Energized Glowstone"] = 144,
}
},
["Energized Glowstone"] = {
amount = 144,
recipe = {
["Glowstone Dust"] = 1,
}
}
}
return recipes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment