Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SLOT_COUNT = 16
- local E_Orb = peripheral.wrap("bottom")
- -- Checks if the energizing orb is busy or if it's free
- function itemsDroppable(orb)
- item = orb.getItemDetail(2)
- if(item == nil) then
- for slot = 1, SLOT_COUNT, 1 do
- local item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- return true
- end
- end
- else
- return false
- end
- end
- -- Inserts the items into the energizing orb
- function dropItems(orb)
- local itemName = ""
- local insert = true
- -- Cycle to insert items into the energizing orb
- for slot = 1, SLOT_COUNT, 1 do
- local item = turtle.getItemDetail(slot)
- if (item ~= nil) then
- if (insert) then
- turtle.select(slot)
- if (item["name"] == "minecraft:redstone_block") then
- turtle.dropDown(2)
- else
- turtle.dropDown(1)
- end
- end
- if (insert) then
- insert = checkForDupes(item["name"])
- end
- end
- end
- end
- -- Checks for multiple stacks of the same item
- function checkForDupes(itemName)
- for i = 1, SLOT_COUNT, 1 do
- local item = turtle.getItemDetail(i)
- if(item ~= nil) then
- if (itemName == item["name"]) then
- return false
- else
- return true
- end
- end
- end
- end
- -- Waits for the machine to complete the items processing
- -- and extracts the results, proceeds then to drop the items
- -- in a storage placed above
- function handleResults(orb)
- while true do
- resultSlot = orb.getItemDetail(1)
- if (resultSlot ~= nil) then
- turtle.select(16)
- turtle.suckDown()
- turtle.dropUp()
- turtle.select(1)
- break
- end
- end
- end
- --
- function getLoops(orb)
- item = orb.getItemDetail(2)
- maxLoops = 0
- if(item == nil) then
- for slot = 1, SLOT_COUNT, 1 do
- local item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- if (item["count"]) then
- maxLoops = item["count"]
- end
- end
- end
- end
- return maxLoops
- end
- -- CheckItems checks if all the items inside the turtle are
- -- legal items to be dropped inside the energizing orb
- function checkItems(itemNames)
- for slot = 1, SLOT_COUNT, 1 do
- local item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- notFoundInList = true
- for i = 1, 13, 1 do
- if (item["name"] == itemNames[i]) then
- notFoundInList = false
- break
- end
- end
- if (notFoundInList) then
- turtle.select(slot)
- turtle.dropUp()
- end
- end
- end
- end
- -- Creates the items map of legal items for the energizing orb
- function createMap()
- tab = {}
- table.insert(tab, 1, "minecraft:emerald")
- table.insert(tab, 2, "minecraft:diamond")
- table.insert(tab, 3, "minecraft:redstone_block")
- table.insert(tab, 4, "minecraft:blaze_rod")
- table.insert(tab, 5, "minecraft:iron_ingot")
- table.insert(tab, 6, "minecraft:gold_ingot")
- table.insert(tab, 7, "minecraft:nether_star")
- table.insert(tab, 8, "minecraft:ender_eye")
- table.insert(tab, 9, "powah:dielectric_casing")
- table.insert(tab, 10, "powah:capacitor_basic_tiny")
- table.insert(tab, 11, "powah:blazing_crystal_block")
- table.insert(tab, 12, "minecraft:blue_ice")
- table.insert(tab, 13, "minecraft:snowball")
- return tab
- end
- itemNames = createMap()
- while true do
- table.foreach(itemNames, print)
- checkItems(itemNames)
- if (itemsDroppable(E_Orb)) then
- sleep(0.75)
- dropItems(E_Orb)
- handleResults(E_Orb)
- end
- end
Add Comment
Please, Sign In to add comment