Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("turtleChest.lua")
- --pick and modem swapped in left, chunkloader in right
- maxturtles = 3
- mineableItems = {
- { "minecraft:iron_ore", "minecraft:raw_iron" },
- { "minecraft:deepslate_iron_ore", "minecraft:raw_iron"},
- {"minecraft:redstone_ore", "minecraft:redstone"},
- { "minecraft:deepslate_redstone_ore", "minecraft:redstone"},
- {"minecraft:gold_ore", "minecraft:raw_gold"},
- { "minecraft:deepslate_gold_ore", "minecraft:raw_gold"},
- { "minecraft:deepslate_diamond_ore", "minecraft:diamond" },
- { "minecraft:diamond_ore", "minecraft:diamond" },
- { "minecraft:nether_quartz_ore", "minecraft:quartz" },
- { "minecraft:ancient_debris", "minecraft:netherite_scrap" }
- }
- function isChestInFront()
- local success, data = turtle.inspect()
- if success and data.name:find("chest") then
- return true
- end
- return false
- end
- function findItemSlot(itemName)
- for slot = 1, 16 do
- local itemDetail = turtle.getItemDetail(slot)
- if itemDetail and itemDetail.name == itemName then
- return slot
- end
- end
- return nil
- end
- function insertAll()
- for slot = 1, 16 do
- if turtle.getItemCount(slot) > 0 and slot ~= findItemSlot("computercraft:wireless_modem_advanced") and slot ~= findItemSlot("minecraft:diamond_pickaxe") then
- turtle.select(slot)
- turtle.drop()
- end
- end
- turtle.select(1)
- end
- function findTurtleAmount(maxturtles)
- maxheight = (31 * maxturtles) + 15
- cx, cy, cz = gps.locate()
- if cy - maxheight < -58 then
- return math.floor((maxheight + 58) / 31)
- else
- return maxturtles
- end
- end
- function buildChest()
- turtle.digUp()
- turtle.up()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- turtle.turnRight()
- slot = findItemSlot("minecraft:chest")
- if slot == nil then
- print("chest not found")
- os.exit(1)
- else
- turtle.select(slot)
- turtle.placeDown()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- slot = findItemSlot("minecraft:chest")
- if slot == nil then
- print("chest not found")
- os.exit(1)
- else
- turtle.placeDown()
- turtle.turnLeft()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.digDown()
- turtle.down()
- slot = findItemSlot("minecraft:chest")
- if slot ~= nil then
- turtle.select(slot)
- turtle.drop()
- end
- end
- end
- end
- function placeTurtles(turtles)
- if not isChestInFront() then
- buildChest()
- end
- for i = 1, turtles do
- for j = 1, 31 do
- turtle.digDown()
- turtle.down()
- end
- turtle.dig()
- slot = findItemSlot("computercraft:turtle_normal")
- if slot == nil then
- print("turtle not found")
- else
- turtle.select(slot)
- turtle.place()
- slot2 = findItemSlot("computercraft:wireless_modem_normal")
- if slot2 ~= nil then
- turtle.select(slot2)
- turtle.drop(1)
- target = peripheral.wrap("front")
- target.turnOn()
- else
- print("modem not found")
- end
- end
- end
- for i = 1, turtles do
- for j = 1, 31 do
- turtle.digUp()
- turtle.up()
- end
- end
- insertAll()
- slot = findItemSlot("computercraft:wireless_modem_advanced")
- turtle.select(slot)
- turtle.equipLeft()
- rednet.open("left")
- for i = 1, turtles * turtles do
- rednet.broadcast(mineableItems)
- end
- for i = 1, turtles do
- id, workerstatus = rednet.receive() --this process should have a large time limit for worst case scenario.
- end
- slot = findItemSlot("minecraft:diamond_pickaxe")
- turtle.select(slot)
- turtle.equipLeft()
- end
- function collectOre(turtles)
- for i = 1, turtles do
- for j = 1, 31 * i do
- turtle.digDown()
- turtle.down()
- end
- turtleChest.takeAll()
- for j = 1, 31 * i do
- turtle.digUp()
- turtle.up()
- end
- insertAll()
- --add feature to go to top and deposit
- end
- end
- function collectTurtles(turtles)
- for i = 1, turtles do
- for j = 1, 31 do
- turtle.digDown()
- turtle.down()
- end
- turtle.dig()
- end
- for i = 1, turtles do
- for j = 1, 31 do
- turtle.digUp()
- turtle.up()
- end
- end
- end
- slot = findItemSlot("computercraft:wireless_modem_advanced")
- if slot == nil then
- print("modem not found")
- os.exit(1)
- end
- turtle.select(slot)
- turtle.equipLeft()
- rednet.open("left")
- turtles = findTurtleAmount(maxturtles)
- if turtles == 0 then
- os.exit(1)
- end
- slot = findItemSlot("minecraft:diamond_pickaxe")
- turtle.select(slot)
- turtle.equipLeft()
- placeTurtles(turtles)
- collectOre(turtles)
- collectTurtles(turtles)
Advertisement
Add Comment
Please, Sign In to add comment