Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Original by Palagius : https://oc.cil.li/index.php?/topic/1426-ae2-level-auto-crafting/
- -- Modfied by Dalden 2018-07-28
- -- - Store crafting result object to check for status
- -- - If crafting job is not yet finished from previous cycle then skip this cycle
- local component = require("component")
- local meController = component.proxy(component.me_controller.address)
- local gpu = component.gpu
- -- Each element of the array is "item", "damage", "number wanted", "max craft size"
- -- Damage value should be zero for base items
- items = {
- -- Applied Energistics
- { "appliedenergistics2:material", 24, 10000, 1000 }, -- Engineering Processor
- { "appliedenergistics2:material", 23, 10000, 1000 }, -- Calculation Processor
- { "appliedenergistics2:material", 22, 10000, 1000 }, -- Logic Processor
- { "appliedenergistics2:part", 56, 1000, 100 }, -- ME Smart Cable
- { "appliedenergistics2:part", 76, 1000, 100 }, -- ME Dense Smart Cable
- { "appliedenergistics2:part", 140, 1000, 100 }, -- Quartz Fiber
- { "appliedenergistics2:part", 120, 1000, 100 }, -- Cable Anchor
- { "appliedenergistics2:interface", 0, 100, 10 }, -- ME Interface
- { "appliedenergistics2:part", 440, 1000, 100 }, -- Me Interface
- { "appliedenergistics2:part", 260, 1000, 100 }, -- Export Bus
- { "appliedenergistics2:part", 240, 1000, 100 }, -- Import Bus
- { "appliedenergistics2:part", 280, 100, 10 }, -- ME Level Emitter
- { "appliedenergistics2:part", 460, 100, 10 }, -- P2P Tunnel - ME
- { "appliedenergistics2:material", 25, 1000, 1000 }, -- Basic Card
- { "appliedenergistics2:material", 27, 1000, 100 }, -- Capacity Card
- { "appliedenergistics2:material", 53, 1000, 100 }, -- Crafting Card
- { "appliedenergistics2:material", 26, 1000, 100 }, -- Redstone Card
- { "appliedenergistics2:material", 28, 1000, 1000 }, -- Advanced Card
- { "appliedenergistics2:material", 29, 1000, 100 }, -- Fuzzy Card
- { "appliedenergistics2:material", 31, 1000, 100 }, -- Inverter Card
- { "appliedenergistics2:material", 30, 1000, 100 }, -- Acceleration Card
- { "appliedenergistics2:crafting_storage_64k", 0 , 100, 10 }, -- 64k Crafting Unit
- { "appliedenergistics2:crafting_monitor", 0 , 10, 1 }, -- Crafting Monitor
- { "appliedenergistics2:crafting_accelerator", 0 , 100, 10 }, -- Crafting Co-Processor
- { "extracells:storage.physical", 3 , 10, 1 }, -- 16384k Storage
- { "appliedenergistics2:dense_energy_cell", 0 , 500, 50 }, -- Dense Energy Cell
- { "appliedenergistics2:fluid_storage_cell_1k", 0, 100, 10 }, -- 1k ME Fluid Storage Cell
- { "appliedenergistics2:fluid_storage_cell_64k", 0, 10, 1 }, -- 64k ME Fluid Storage Cell
- { "appliedenergistics2:part", 261, 1000, 100 }, -- Fluid Export Bus
- { "appliedenergistics2:part", 241, 1000, 100 }, -- Fluid Import Bus
- { "appliedenergistics2:part", 281, 100, 10 }, -- ME Fluid Level Emitter
- -- Draconic Evolution
- { "draconicevolution:draconic_core", 0, 1000, 100 }, -- Draconic Core
- { "draconicevolution:wyvern_energy_core", 0, 100, 10 }, -- Wyvern Energy Core
- { "draconicevolution:wyvern_core", 0, 100, 10 }, -- Wyvern Core
- { "draconicevolution:draconium_block", 0, 1000, 100 }, -- Block of Draconium
- { "draconicevolution:draconium_dust", 0, 10000, 1000 }, -- Draconium Dust
- -- Mekanism
- { "mekanism:controlcircuit", 0, 1000, 100 }, -- Basic Control Circuit
- { "mekanism:controlcircuit", 1, 1000, 100 }, -- Advanced Control Circuit
- { "mekanism:controlcircuit", 2, 1000, 100 }, -- Elite Control Circuit
- { "mekanism:reinforcedalloy", 0 , 1000, 100 }, -- Reinforced Alloy
- { "mekanism:atomicalloy", 0 , 1000, 100 }, -- Atomic Alloy
- -- Crafting Materials
- { "minecraft:ender_eye", 0 , 1000, 100 }, -- Ender Eye
- { "minecraft:string", 0 , 10000, 1000 }, -- String
- { "extendedcrafting:material", 24 , 1000, 100 }, -- Crystaline Ingot
- -- Fusion Reactor
- { "nuclearcraft:fusion_core", 0 , 10, 1 }, -- Fusion Core
- { "nuclearcraft:fusion_electromagnet_transparent_idle", 0 , 1000, 100 }, -- Clear Electromagnet
- { "nuclearcraft:fusion_electromagnet_idle", 0 , 1000, 100 }, -- Electromagnet
- { "nuclearcraft:fusion_connector", 0 , 100, 10 }, -- Connector
- --Fision Reactor
- { "nuclearcraft:reactor_casing_transparent", 0 , 1000, 100 }, -- NAME
- { "nuclearcraft:fission_block", 0 , 200, 20 }, -- NAME
- { "nuclearcraft:fission_controller_new_fixed", 0 , 10, 1 }, -- NAME
- { "nuclearcraft:fission_port", 0 , 100, 10 }, -- NAME
- { "nuclearcraft:cell_block", 0 , 200, 20 }, -- NAME
- { "nuclearcraft:ingot_block", 8 , 200, 20 }, -- NAME
- { "nuclearcraft:cooler", 0 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 1 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 2 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 3 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 4 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 5 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 6 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 7 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 8 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 9 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 10, 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 11 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 12 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 13 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 14 , 500, 50 }, -- NAME
- { "nuclearcraft:cooler", 15 , 500, 50 }, -- NAME
- -- Mystical Agricalture
- { "mysticalagriculture:crafting", 1 , 1000, 100 }, -- NAME
- { "mysticalagriculture:crafting", 2 , 1000, 100 }, -- NAME
- { "mysticalagriculture:crafting", 3 , 1000, 100 }, -- NAME
- { "mysticalagriculture:crafting", 4 , 1000, 100 }, -- NAME
- { "mysticalagradditions:insanium", 0 , 1000, 100 }, -- NAME
- { "mysticalagriculture:storage", 0, 1000, 100 }, -- NAME
- { "mysticalagriculture:storage", 1 , 1000, 100 }, -- NAME
- { "mysticalagriculture:storage", 2 , 1000, 100 }, -- NAME
- { "mysticalagriculture:storage", 3 , 1000, 100 }, -- NAME
- { "mysticalagriculture:storage", 4 , 1000, 100 }, -- NAME
- { "mysticalagradditions:storage", 0 , 1000, 100 }, -- NAME
- { "mysticalagriculture:crafting", 32 , 1000, 100 }, -- NAME
- { "mysticalagriculture:crafting", 34 , 1000, 100 }, -- NAME
- { "mysticalagriculture:crafting", 35 , 1000, 100 }, -- NAME
- { "mysticalagriculture:crafting", 36 , 1000, 100 }, -- NAME
- { "mysticalagriculture:crafting", 37 , 1000, 100 }, -- NAME
- { "mysticalagradditions:insanium", 2 , 1000, 100 }, -- NAME
- { "mysticalagriculture:growth_accelerator", 0 , 1000, 100 }, -- NAME
- { "cyclicmagic:sprinkler", 0 ,300, 30 }, -- NAME
- }
- loopDelay = 2 -- Seconds between runs
- -- Init list with crafting status
- for curIdx = 1, #items do
- items[curIdx][5] = false -- Crafting status set to false
- items[curIdx][6] = nil -- Crafting object null
- end
- while true do
- for curIdx = 1, #items do
- curName = items[curIdx][1]
- curDamage = items[curIdx][2]
- curMinValue = items[curIdx][3]
- curMaxRequest = items[curIdx][4]
- curCrafting = items[curIdx][5]
- curCraftStatus = items[curIdx][6]
- -- io.write("Checking for " .. curMinValue .. " of " .. curName .. "\n")
- storedItem = meController.getItemsInNetwork({
- name = curName,
- damage = curDamage
- })
- --io.write(storedItem.n)
- -- IF ITEM NOT IN SYSTEM GET storedItem FROM COBBLESTONE FOR FORMAT THEN APPLY CURRENT VALUES
- if storedItem.n == 0 then
- storedItem = meController.getItemsInNetwork({
- name = "minecraft:cobblestone",
- damage = 0
- })
- storedItem[1].name = curName
- storedItem[1].size = 0
- storedItem[1].label = "missing item"
- end
- gpu.setForeground(0xCC24C0) -- Purple-ish
- io.write(storedItem[1].label)
- gpu.setForeground(0xFFFFFF) -- White
- io.write(" - ")
- gpu.setForeground(0xFFFF00) -- Yellow
- io.write(math.floor(storedItem[1].size))
- gpu.setForeground(0xFFFFFF) -- White
- io.write(" of ")
- gpu.setForeground(0xFFFF00) -- Yellow
- io.write(curMinValue)
- gpu.setForeground(0xFFFFFF) -- White
- io.write(" - ")
- if storedItem[1].size < curMinValue then
- delta = curMinValue - storedItem[1].size
- craftAmount = curMaxRequest
- io.write("Stockpile Shortfall of: ")
- gpu.setForeground(0xFF0000) -- Red
- io.write(math.floor(delta))
- gpu.setForeground(0xFFFFFF) -- White
- io.write(" - Requesting: ")
- gpu.setForeground(0xFF0000) -- Red
- io.write(craftAmount)
- gpu.setForeground(0xFFFFFF) -- White
- io.write(" - ")
- craftables = meController.getCraftables({
- name = curName,
- damage = curDamage
- })
- if craftables.n >= 1 then
- cItem = craftables[1]
- if curCrafting then
- if curCraftStatus.isCanceled() or curCraftStatus.isDone() then
- items[curIdx][5] = false
- curCrafting = false
- end
- end
- if curCrafting then
- io.write("Previous Craft busy\n")
- end
- if not curCrafting then
- retval = cItem.request(craftAmount)
- items[curIdx][5] = true
- items[curIdx][6] = retval
- io.write("Crafting Request Made\n")
- os.sleep(15)
- --gpu.setForeground(0x00FF00) -- Green
- --io.write("Requested\n")
- --gpu.setForeground(0xFFFFFF) -- White
- --while (not retval.isCanceled()) and (not retval.isDone()) do
- -- os.sleep(1)
- -- io.write(".")
- --end
- --io.write("Done \n")
- end
- else
- gpu.setForeground(0xFF0000) -- Red
- io.write(" Unable to locate craftable for " .. storedItem[1].name .. "\n")
- gpu.setForeground(0xFFFFFF) -- White
- end
- else
- delta = storedItem[1].size - curMinValue
- io.write("Stockpile Surplus of: ")
- gpu.setForeground(0x00FF00) -- Green
- io.write(math.floor(delta))
- io.write("\n")
- gpu.setForeground(0xFFFFFF) -- White
- end
- --io.write("Sleeping for " .. loopDelay .. " seconds...\n\n")
- os.sleep(loopDelay)
- end
- io.write("\nLoop done, Starting Over!\n\n")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement