Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --dofile("recipes")
- recipes = {
- MotorLUV = { label = "Gold Nugget", items = { { 1, 1 }, { 2, 2 }, { 3, 64 }, { 3, 64 }, { 3, 64 }, { 3, 64 }, { 4, 2 } }, fluids = { { 5, 144 }, { 6, 250 } } },
- PistonLUV = { label = "Sand", items = { { 13, 1 }, { 7, 6 }, { 8, 4 }, { 9, 32 }, { 10, 4 }, { 11, 1 }, { 12, 2 }, { 4, 4 } }, fluids = { { 5, 144 }, { 6, 250 } } },
- RoboarmLUV = { label = "Stone", items = { { 2, 4 }, { 11, 1 }, { 12, 3 }, { 13, 2 }, { 14, 1 }, { 15, 2 }, { 16, 2 }, { 17, 6 }, { 4, 6 } }, fluids = { { 5, 576 }, { 6, 250 } } },
- MotorZPM = { label = "Dirt", items = { { 1, 2 }, { 18, 4 }, { 19, 4 }, { 20, 16 }, { 21, 64 }, { 21, 64 }, { 21, 64 }, { 21, 64 }, { 22, 2 } }, fluids = { { 5, 288 }, { 6, 750 } } },
- PistonZPM = { label = "Gravel", items = { { 27, 1 }, { 23, 6 }, { 19, 4 }, { 20, 32 }, { 24, 4 }, { 25, 1 }, { 26, 2 }, { 22, 4 } }, fluids = { { 5, 288 }, { 6, 750 } } },
- RoboarmZPM = { label = "Coal", items = { { 18, 4 }, { 25, 1 }, { 26, 3 }, { 27, 2 }, { 28, 1 }, { 15, 4 }, { 16, 4 }, { 17, 12 }, { 22, 6 } }, fluids = { { 5, 1152 }, { 6, 750 } } },
- EmiterLUV = { label = "Sugar", items = { { 29, 1 }, { 31, 1 }, { 32, 2 }, { 33, 4 }, { 17, 7 }, { 30, 64 }, { 30, 64 }, { 30, 64 }, { 4, 7 } }, fluids = { { 5, 576 } } },
- EmiterZPM = { label = "Redstone", items = { { 35, 1 }, { 34, 1 }, { 31, 2 }, { 32, 4 }, { 16, 7 }, { 36, 64 }, { 36, 64 }, { 36, 64 }, { 22, 7 } }, fluids = { { 5, 576 } } },
- ConveyorLUV = { label = "Paper", items = { { 13, 2 }, { 7, 2 }, { 8, 4 }, { 9, 32 }, { 4, 2 } }, fluids = { { 37, 1440 }, { 6, 250 } } },
- ConveyorZPM = { label = "Flint", items = { { 27, 2 }, { 23, 2 }, { 19, 4 }, { 20, 32 }, { 22, 2 } }, fluids = { { 37, 2880 }, { 6, 750 } } },
- FieldGeneratorLUV = { label = "Bricks", items = { { 29, 1 }, { 7, 6 }, { 39, 1 }, { 34, 4 }, { 15, 8 }, { 38, 64 }, { 38, 64 }, { 38, 64 }, { 38, 64 }, { 4, 8 } }, fluids = { { 5, 576 } } },
- NeuroProcessingUnit = { label = "Grass", items = { { 43, 1 }, { 42, 8 }, { 45, 8 }, { 44, 4 }, { 49, 8 }, { 46, 64 }, { 47, 4 } }, fluids = { { 40, 250 }, { 41, 100 }, { 48, 1000 } } },
- LapatronLUV = { label = "Apple", items = { { 58, 1 }, { 50, 32 }, { 51, 4 }, { 52, 36 }, { 52, 36 }, { 53, 64 }, { 57, 32 }, { 56, 32 }, { 54, 32 }, { 55, 32 }, { 21, 64 } }, fluids = { { 5, 720 } } },
- BatteryZPM = { label = "Glass", items = { { 59, 16 }, { 60, 1 }, { 60, 1 }, { 60, 1 }, { 60, 1 }, { 61, 8 }, { 62, 2 }, { 63, 64 }, { 63, 64 }, { 57, 8 }, { 64, 32 } }, fluids = { { 5, 2880 }, { 48, 16000 } } },
- TEST = { label = "Carrot", items = { { 3, 16 }, { 3, 16 }, { 3, 16 }, { 3, 16 }, { 3, 16 }, { 3, 16 }, { 3, 16 }, { 3, 16 } }, fluids = { } },
- }
- local sides = require("sides")
- local comp = require("component")
- local tp = comp.proxy("b1becc1e-4445-432e-97f0-f33a588c162e")
- local outputTp = comp.proxy("1b1f8e79-318c-47a3-958e-4234af111a2a")
- local rs = comp.redstone
- local meItem = comp.proxy("1637b950-8a1b-4fa6-903b-9b4419e4e319")
- local meFluid = comp.proxy("26e1d51c-dc6f-40af-ae6c-0282d4ce76f6")
- local db = comp.database
- local assLine = comp.gt_machine
- local gpu = comp.gpu
- -- мультижидкости крекер
- local oilTp = comp.proxy("04c928eb-1d3d-4780-aaa7-921c5b736541")
- local fSides = { sides.north, sides.west, sides.east }
- local recipeChestSide = sides.right
- local itemIntSide = sides.left
- local redItemSide = sides.back
- local redfluidSide = sides.left
- local inputChestSide = sides.back
- local outputChestSide = sides.front
- local outputInterfaceSide = sides.right
- local inputTankSide = sides.bottom
- local fluidIntSide = sides.front -- с какой стороны от транспозера стоит ж интерфейс
- local fluidIntTankSide = sides.back -- с какой стороны от ж интерфейса стоит транспозер
- local clear = " "
- local streamMode = false
- local recipeName = "missing" .. clear
- local prevRecipeName = "missing" .. clear
- local line = 0
- local colors = {
- white = 0xffffff,
- orange = 0xff9200,
- magenta = 0xff00ff,
- lightblue = 0x99dbff,
- yellow = 0xffff00,
- lime = 0x00ff00,
- pink = 0xffb6bf,
- gray = 0x787878,
- silver = 0xc3c3c3,
- cyan = 0x00ffff,
- purple = 0x990080,
- blue = 0x0000ff,
- brown = 0x992440,
- green = 0x009200,
- red = 0xff0000,
- black = 0x000000
- }
- local e = 1
- function oilCrackingUnit()
- gpu.set(106,45, "OilCreacingUnit")
- if oilTp.getFluidInTank(sides.south, 1).amount == 0 then
- n = 1
- while true do
- if oilTp.getFluidInTank(fSides[e], 1).amount >= oilTp.getFluidInTank(sides.south, 1).capacity then
- oilTp.transferFluid(fSides[e], sides.south, oilTp.getFluidInTank(sides.south, 1).capacity)
- gpu.set(126,45, "transfer " .. e)
- if e == 3 then
- e = 1
- else
- e = e + 1
- end
- return
- end
- if e == 3 then
- e = 1
- else
- e = e + 1
- end
- if (n >= 3) then
- gpu.set(126,45, "no fluids")
- return
- end
- n = n + 1
- end
- end
- end
- function dbPrint()
- local s1, s2, l1, l2, len, temp
- len = 38
- gpu.set(38, 1, "Data Base List")
- for i = 1, 81, 2 do
- temp = ((i + 1) / 2) + 1
- s1 = db.get(i)
- if (s1 ~= nil) then
- l1 = s1.label
- l1 = string.sub(l1, 1, len)
- else
- l1 = "empty"
- end
- gpu.set(1, temp, tostring(i))
- gpu.set(4, temp, l1)
- if i < 81 then
- s2 = db.get(i + 1)
- if (s2 ~= nil) then
- l2 = s2.label
- l2 = string.sub(l2, 1, len)
- else
- l2 = "empty"
- end
- gpu.set(44, temp, tostring(i + 1))
- gpu.set(48, temp, l2)
- end
- line = (i + 1) / 2
- end
- end
- function init()
- gpu.fill(1, 1, 160, 50, ' ')
- gpu.set(100, 1, "║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║", true)
- gpu.set(101, 1, " OC/AE automation integration GT5U Assembly Line")
- gpu.set(160 - 27, 50, "Desing by Dimach and Clor#D")
- gpu.set(106, 5, "Stream Mode status")
- gpu.set(106, 6, "Preparing recipe ")
- gpu.set(106, 7, "Crafting recipe ")
- gpu.set(106, 8, "Assembly Line status")
- n = 20
- gpu.set(106, n, "Recipes List : ")
- for k, _ in pairs(recipes) do
- n = n + 1
- gpu.set(106, n, k)
- end
- dbPrint()
- end
- local offset = 106 + 22
- function update()
- gpu.set(offset, 5, tostring(streamMode) .. clear)
- gpu.set(offset, 6, recipeName)
- gpu.set(offset, 7, prevRecipeName)
- if assLine.hasWork() then
- gpu.set(offset, 8, " ")
- gpu.setBackground(colors.green)
- gpu.set(offset, 8, "enable")
- else
- gpu.setBackground(colors.red)
- gpu.set(offset, 8, "disable")
- end
- gpu.setBackground(colors.black)
- end
- function cPrint(str)
- s = string.sub(str, 1, 99)
- if line < 50 then
- line = line + 1
- gpu.set(1, line, s)
- else
- gpu.copy(1, 1, 99, 50, 0, -1)
- gpu.set(1, line, clear)
- gpu.set(1, line, s)
- end
- update()
- end
- function moveItems(recipe)
- cPrint("Start moving items")
- for k, v in ipairs(recipe.items) do
- local stackLabel = db.get(v[1]).label
- local stack
- local toChest
- local recCount = v[2]
- local count = 0
- for i = 1, 9 do
- stack = tp.getStackInSlot(recipeChestSide, i)
- if stack ~= nil and stack.label == stackLabel then
- count = count + stack.size
- end
- end
- if count >= recCount then
- local n = 1
- while recCount > 0 or n <= 9 do
- stack = tp.getStackInSlot(recipeChestSide, n)
- if stack ~= nil and stack.label == stackLabel then
- if recCount <= stack.size then
- tp.transferItem(recipeChestSide, inputChestSide, recCount, n, 1)
- cPrint("Transfer from chest " .. stackLabel)
- recCount = 0
- else
- tp.transferItem(recipeChestSide, inputChestSide, stack.size, n, 1)
- recCount = recCount - stack.size
- cPrint("Transfer part from chest " .. stackLabel)
- end
- end
- n = n + 1
- end
- toChest = true
- else
- toChest = false
- end
- if (not toChest) then
- cPrint("Request " .. stackLabel)
- meItem.setInterfaceConfiguration(1, db.address, v[1], v[2])
- cPrint("Wait " .. stackLabel)
- repeat
- os.sleep(0.5)
- stack = tp.getStackInSlot(itemIntSide, 1)
- until stack ~= nul and stack.size == v[2] and stack.label == stackLabel
- cPrint("Transfer " .. stackLabel)
- tp.transferItem(itemIntSide, inputChestSide, v[2], 1, 1)
- meItem.setInterfaceConfiguration(1, db.address, 1, 0)
- end
- rs.setBundledOutput(redItemSide, k - 1, 255)
- os.sleep(1)
- rs.setBundledOutput(redItemSide, k - 1, 0)
- cPrint("Done " .. stackLabel)
- end
- cPrint("Items ready")
- end
- function moveFluids(recipe)
- cPrint("Start moving fluids")
- for k, v in ipairs(recipe.fluids) do
- local stackLabel = db.get(v[1]).label
- local stack
- local recCount = v[2]
- cPrint("Request " .. stackLabel)
- meFluid.setFluidInterfaceConfiguration(fluidIntTankSide, db.address, v[1])
- cPrint("Wait " .. stackLabel)
- while recCount > 10000 do
- repeat
- os.sleep(0.5)
- stack = tp.getTankLevel(fluidIntSide, 1)
- until stack == 10000
- cPrint("Transfer 10000L " .. stackLabel)
- tp.transferFluid(fluidIntSide, inputTankSide, 10000)
- recCount = recCount - 10000
- end
- repeat
- os.sleep(0.5)
- stack = tp.getTankLevel(fluidIntSide, 1)
- until stack >= recCount
- cPrint("Transfer " .. stackLabel)
- tp.transferFluid(fluidIntSide, inputTankSide, recCount)
- meFluid.setFluidInterfaceConfiguration(fluidIntTankSide, db.address, 0)
- rs.setBundledOutput(redfluidSide, k - 1, 255)
- repeat
- os.sleep(0.5)
- until (tp.getTankLevel(fluidIntSide, 1) == 0) and (tp.getTankLevel(inputTankSide, 1) == 0)
- rs.setBundledOutput(redfluidSide, k - 1, 0)
- cPrint("Done " .. stackLabel)
- end
- cPrint("Fluids ready")
- end
- init()
- while true do
- cPrint("System standby...")
- local checkItem
- repeat
- os.sleep(0.5)
- oilCrackingUnit()
- checkItem = tp.getStackInSlot(recipeChestSide, 1)
- if outputTp.getStackInSlot(outputChestSide, 1) ~= nil then
- outputTp.transferItem(outputChestSide, outputInterfaceSide, 64, 1, 8)
- cPrint(prevRecipeName .. " Ready")
- prevRecipeName = "missing" .. clear
- streamMode = false
- update()
- end
- until checkItem ~= nil
- local recipe
- for k, v in pairs(recipes) do
- if v.label == checkItem.label then
- cPrint("Found valid recipe: " .. k)
- recipeName = k
- recipe = v
- break
- end
- end
- if recipe ~= nil then
- moveItems(recipe)
- moveFluids(recipe)
- if streamMode then
- repeat
- os.sleep(0.5)
- until outputTp.getStackInSlot(outputChestSide, 1) ~= nil
- repeat
- os.sleep(0.5)
- until assLine.hasWork()
- for i = 9, 1, -1 do
- tp.transferItem(recipeChestSide, itemIntSide, 64, i, i)
- end
- cPrint("Recipe chest clear")
- outputTp.transferItem(outputChestSide, outputInterfaceSide, 64, 1, 8)
- cPrint(prevRecipeName .. " Ready")
- prevRecipeName = "missing" .. clear
- update()
- else
- repeat
- os.sleep(0.5)
- until assLine.hasWork()
- for i = 9, 1, -1 do
- tp.transferItem(recipeChestSide, itemIntSide, 64, i, i)
- end
- end
- streamMode = true
- prevRecipeName = recipeName
- recipeName = "missing" .. clear
- update()
- else
- cPrint("Marker invalid: " .. checkItem.label)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment