Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sides = require("sides")
- local component = require("component")
- local chest_transposer = {}
- local in_chest = {}
- local out_chest = {}
- local tanks = {}
- local tank_output = sides.up
- local recipes = {
- ["Basic Circuit Board"] = {fluid = "Water", amount = 5000},
- ["Enhanced Circuit Board"] = {fluid = "Water", amount = 5000},
- ["Refined Circuit Board"] = {fluid = "Water", amount = 5000},
- ["Mulch"] = {fluid = "Water", amount = 5000},
- ["Hardened Casing"] = {fluid = "Water", amount = 5000},
- ["Impregnated Casing"] = {fluid = "Seed Oil", amount = 125},
- ["Impregnated Stick"] = {fluid = "Seed Oil", amount = 50},
- ["Wyvern Energy Core"] = {fluid = "Destabilized Redstone", amount = 10000},
- ["Random Animal 1"] = {fluid = "Liquid Meat", amount = 125},
- ["Random Animal 2"] = {fluid = "Liquid DNA", amount = 250},
- ["Overclocker Upgrade"] = {fluid = "IC2 Coolant", amount = 1500},
- ["Tier 6 Crafting Seed"] = {fluid = "Sewage", amount = 500},
- ["Bog Earth"] = {fluid = "Water", amount = 2000},
- ["Draconic Energy Core"] = {fluid = "Primal Mana", amount = 500},
- ["Crafting Core"] = {fluid = "Liquifacted Coal", amount = 2500},
- ["Pedestal"] = {fluid = "Liquifacted Coal", amount = 500},
- ["Intricate Circuit Board"] = {fluid = "Water", amount = 5000},
- ["Wyvern Core"] = {fluid = "Primal Mana", amount = 500},
- ["Ludicrite Block"] = {fluid = "Liquid DNA", amount = 500}
- }
- function print_table (t)
- for key, value in pairs(t) do
- print(key, value)
- end
- end
- function table_length(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- print("Scanning transposers...")
- for address, name in component.list("transposer", false) do
- local t = component.proxy(address)
- local is_chest = false
- for i=0,5,1 do
- local name = t.getInventoryName(i)
- if not (name == nil) then
- if string.match(name, "chest") then
- if name == "minecraft:chest" then
- in_chest = i
- print("Input chest found on transposer:", address)
- else
- out_chest = i
- print("Output chest found on transposer:", address)
- end
- chest_transposer = t
- else
- if not (i == tank_output) then
- local fluid = t.getFluidInTank(i, 1).label
- local tank = {}
- tank.transposer = t
- tank. side = i
- tank.transfer = function (amount)
- return tank.transposer.transferFluid(tank.side, tank_output, amount)
- end
- tank.get_level = function ()
- return tank.transposer.getTankLevel(tank.side, 1)
- end
- tanks[fluid] = tank
- print("Input tank of", fluid, "found on transposer:", address)
- else
- print("Output tank found on transposer:", address)
- end
- end
- end
- end
- end
- print("Scanning complete")
- while true do
- local raw_items = chest_transposer.getAllStacks(in_chest)
- local items = {}
- for i=1,6,1 do
- if not (raw_items[i].size == 0) then
- local item_name = raw_items[i].label
- local item_amount = raw_items[i].size
- items[item_name] = item_amount
- end
- end
- if not (table_length(items) == 0) then
- local recipe = ""
- if items["Tin Ingot"] == 1 and
- items["Redstone"] == 2 then
- recipe = "Basic Circuit Board"
- elseif items["Bronze Ingot"] == 1 and
- items["Redstone"] == 2 then
- recipe = "Enhanced Circuit Board"
- elseif items["Iron Ingot"] == 1 and
- items["Redstone"] == 2 then
- recipe = "Refined Circuit Board"
- elseif items["Mulch"] == 1 and
- items["Dirt"] == 8 then
- recipe = "Humus"
- elseif items["Sturdy Casing"] == 1 and
- items["Diamond"] == 4 then
- recipe = "Hardened Casing"
- elseif items["Oak Wood"] == 4 then
- recipe = "Impregnated Casing"
- elseif items["Oak Wood Planks"] == 2 then
- recipe = "Impregnated Stick"
- elseif items["Draconic Core"] == 1 then
- recipe = "Wyvern Energy Core"
- elseif items["Egg"] == 3 and
- items["Magic Bean"] == 1 then
- recipe = "Random Animal 2"
- elseif items["Tin Plate"] == 3 and
- items["Basic Control Circuit"] == 1 and
- items["Copper Cable"] == 1 then
- recipe = "Overclocker Upgrade"
- elseif items["Seeds"] == 4 and --ACCEPTS ANYTHING IN 'listAllseed'
- items["Insanium Essence"] == 2 and
- items["Tier 5 Crafting Seed"] ==1 then
- recipe = "Tier 6 Crafting Seed"
- elseif items["Mulch"] == 1 and
- items["Dirt"] == 2 and
- items["Sand"] == 2 then
- recipe = "Bog Earth"
- elseif items["Awakened Draconium Ingot"] == 2 and
- items["Wyvern Energy Core"] == 4 and
- items["Wyvern Core"] == 1 then
- recipe = "Draconic Energy Core"
- elseif items["Crystaltine Component"] == 3 and
- items["Pedestal"] == 2 and
- items["Osmiridium Ingot"] == 2 then
- recipe = "Crafting Core"
- elseif items["Black Iron Slate"] == 1 and
- items["Block of Black Iron"] == 1 and
- items["Black Iron Ingot"] == 2 then
- recipe = "Pedestal"
- elseif items["Basic Circuit Board"] == 1 and
- items["Enhanced Circuit Board"] == 1 and
- items["Refined Circuit Board"] == 1 and
- items["Printed Engineering Circuit"] == 2 and
- items["Ultimate Control Circuit"] == 1 then
- recipe = "Intricate Circuit Board"
- elseif items["Shulker Shell"] == 1 and
- items["Ludicrite Ingot"] == 2 and
- items["Pladium"] == 1 and
- items["Nether Star"] == 1 and
- items["Draconic Core"] == 3 then
- recipe = "Wyvern Core"
- elseif items["Ender Amethyst"] == 1 and
- items["Blutonium Block"] == 1 and
- items["Alumite Ingot"] == 1 and
- items["Blaze Mesh"] == 1 and
- items["Block of Elementium"] == 1 and
- items["Block of Enderium"] == 2 then
- recipe = "Ludicrite Block"
- end
- if not (recipe == "") then
- print("Recipe detected for", recipe)
- local tank = tanks[recipes[recipe].fluid]
- local fluid_err_msg = false
- repeat
- if (not (tank.get_level() >= recipes[recipe].amount)) and (not fluid_err_msg) then
- print("There is not enough fluid")
- fluid_err_msg = true
- end
- until(tank.get_level() >= recipes[recipe].amount)
- local tank_err_msg = false
- repeat
- local done = tank.transfer(recipes[recipe].amount)
- if (not done) and (not tank_err_msg) then
- print("Unable to export fluid")
- tank_err_msg = true
- end
- until(done)
- for i=1,6,1 do
- local chest_err_msg = false
- local stack_to_transfer_info = chest_transposer.getStackInSlot(in_chest, i)
- local num_to_transfer = 0
- if not (stack_to_transfer_info == nil) then
- num_to_transfer = stack_to_transfer_info.size
- end
- repeat
- local num_transferred = chest_transposer.transferItem(in_chest, out_chest, 64, i, i)
- if (not (num_to_transfer == num_transferred)) and (not chest_err_msg) then
- print("Unable to export into output chest")
- chest_err_msg = true
- end
- until(num_to_transfer == num_transferred)
- end
- print("Recipe completed")
- end
- end
- --break
- os.sleep(0.5)
- end
Add Comment
Please, Sign In to add comment