Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local comp = require("component")
- local term = require("term")
- local event = require("event")
- local gpu = comp.gpu
- local ae = comp.getPrimary("me_controller")
- local craftingList = {}
- local craftingLog = {}
- local crafting = {}
- local toCraft = {
- ["Stick"] = 1000,
- ["Oak Wood Planks"] = 512,
- ["Piston"] = 100 ,
- ["Sticky Piston"] = 100,
- ["Chest"] = 128,
- ["Blaze Powder"] = 64,
- ["Gold Nugget"] = 400,
- ["Cryo-Stabilized Fluxduct"] = 128,
- ["Conduit Binder"] = 64,
- ["Electrical Steel"] = 64,
- ["Energetic Alloy"] = 64,
- ["Vibrant Alloy"] = 64,
- ["Redstone Alloy"] = 64,
- ["Pulsating Iron"] = 64,
- ["Ender Energy Conduit"] = 64,
- ["Item Conduit"] = 64,
- ["Ender Fluid Conduit"] = 64,
- ["Insulated Redstone Conduit"] = 64,
- ["Enriched Alloy"] = 64,
- ["Reinforced Alloy"] = 64,
- ["Atomic Alloy"] = 32,
- ["Basic Control Circuit"] = 64,
- ["Advanced Control Circuit"] = 16,
- ["Elite Control Circuit"] = 16,
- ["Ultimate Control Circuit"] = 2,
- ["Pure Certus Quartz Crystal"] = 64,
- ["Pure Nether Quartz Crystal"] = 64,
- ["Pure Fluix Crystal"] = 64,
- ["Certus Quartz Dust"] = 64,
- ["Fluix Dust"] = 64,
- ["Cable Anchor"] = 64,
- ["Quartz Fiber"] = 64,
- ["ME Glass Cable - Fluix"] = 64,
- ["ME Dense Cable - Fluix"] = 64,
- ["ME Smart Cable - Fluix"] = 64,
- ["Logic Processor"] = 64,
- ["Calculation Processor"] = 64,
- ["Engineering Processor"] = 64,
- ["Formation Core"] = 32,
- ["Annihilation Core"] = 32,
- ["ME Interface"] = 32,
- ["Hardened Glass"] = 64,
- ["Electrum Ingot"] = 64,
- ["Invar Ingot"] = 64,
- ["Signalum Ingot"] = 64,
- ["Lumium Ingot"] = 64,
- ["Enderium Ingot"] = 64,
- ["Bronze Ingot"] = 64,
- ["Steel Ingot"] = 64
- }
- function printLog(text)
- term.setCursor(1,5)
- term.write(" ")
- term.setCursor(1,5)
- term.write(text)
- end
- function printJobs()
- local i = 5
- for k,v in pairs(craftingList) do
- term.setCursor(40,i)
- term.write(" ")
- term.setCursor(40,i)
- term.write(k.." x "..v)
- i = i + 1
- end
- for j=i,25 do
- term.setCursor(40,j)
- term.write(" ")
- end
- end
- function addCraftingToList(name, number)
- craftingList[name] = number
- printJobs()
- end
- function removeCraftingFromList(name)
- for k,v in pairs(craftingList) do
- if k == name then craftingList[k] = nil end
- end
- printJobs()
- end
- function checkCrafting(label)
- if crafting[label] == nil then
- removeCraftingFromList(label)
- return true
- elseif crafting[label].isDone() then
- printLog(label.." done")
- crafting[label] = nil
- removeCraftingFromList(label)
- return false
- elseif crafting[label].isCanceled() then
- printLog(label.." canceled")
- crafting[label] = nil
- removeCraftingFromList(label)
- return false
- else
- return false
- end
- end
- function craftingManager()
- for labelString,number in pairs(toCraft) do
- local craft = nil
- local itemInAE = nil
- local skip = false
- filter = { label = labelString }
- if ae.getCraftables(filter)[1] ~= nil then
- craft = ae.getCraftables(filter)[1]
- else
- skip = true
- end
- if not skip then
- if ae.getItemsInNetwork(filter)[1] ~= nil then
- itemsInAE = ae.getItemsInNetwork(filter)[1]
- else
- itemsInAE= { size = 0 }
- end
- if number-itemsInAE.size > 0 then
- if checkCrafting(labelString) and craft ~= nil then
- crafting[labelString] = craft.request(number-itemsInAE.size)
- if crafting[labelString] == nil or crafting[labelString].isCanceled() == true then
- printLog("fail "..number-itemsInAE.size .. " x " .. labelString)
- crafting[labelString] = nil
- else
- printLog("success "..number-itemsInAE.size .. " x " .. labelString)
- addCraftingToList(labelString,number-itemsInAE.size)
- end
- end
- end
- end
- end
- end
- function main()
- gpu.setResolution(80,25)
- term.clear()
- term.write("CraftingManager by Keridos")
- term.setCursor(1,4)
- term.write("Last Log:")
- term.setCursor(40,4)
- term.write("Current Jobs:")
- while true do
- craftingManager()
- for k,v in pairs(craftingList) do
- checkCrafting(k)
- end
- term.setCursor(1,3)
- term.write(" ")
- os.sleep(1)
- end
- end
- while true do
- pcall(main)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement