Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local enderchestSlot = 1
- local diamondSlot = 2
- local uraniumSlot = 3
- local heightToDig = 70
- local widthToDig = 6 -- actually doubled
- local lengthToDig = 6 -- actually doubled
- term.clear()
- print("Place enderchest in slot 1")
- print("")
- print("Press ENTER to start")
- -- wait untill ENTER is pressed to start
- while true do
- press, key = os.pullEvent()
- if press == "key" and key == 28 then
- break
- end
- end
- local p = peripheral.wrap("left")
- if p ~= nil then -- check if it can connect to the peripheral
- print("")
- print("connected")
- else
- print("")
- print("can't connect")
- end
- print("")
- print("running code")
- print("")
- function digForward()
- local p = peripheral.wrap("left")
- p.dig()
- end
- function digLeft()
- local p = peripheral.wrap("left")
- turtle.turnLeft()
- p.dig()
- turtle.turnRight()
- end
- function digRight()
- local p = peripheral.wrap("left")
- turtle.turnRight()
- p.dig()
- turtle.turnLeft()
- end
- function checkIfFull()
- print("")
- print("checking inventory")
- print("")
- ItemCount=turtle.getItemCount(16)
- if ItemCount > 0 then
- -- the chest is full so we need to turn around and place the enderchest
- turtle.turnLeft()
- turtle.turnLeft()
- p.dig()
- turtle.select(enderchestSlot)
- turtle.place()
- --turtle.sleep(120)
- -- drop everything except diamonds
- for j=2, 16 do
- local data = turtle.getItemDetail(j)
- if data then
- print("Item name: ", data.name)
- if data.name=="minecraft:diamond" then
- turtle.transferTo(diamondSlot)
- end
- if data.name=="IC2:blockOreUran" then
- turtle.transferTo(uraniumSlot)
- end
- if data.name~="minecraft:diamond" and data.name~="IC2:blockOreUran" then
- turtle.select(j)
- turtle.drop()
- end
- end
- end
- -- now we need to break the enderchest and add it back to the inventory
- local p = peripheral.wrap("left")
- turtle.select(enderchestSlot)
- p.dig()
- turtle.turnLeft()
- turtle.turnLeft()
- else
- print("turtle is not full")
- end
- end
- function digForwardGravel()
- if turtle.forward() == false then
- repeat
- p.dig()
- sleep(1)
- until turtle.forward() == true
- end
- end
- function main_code()
- for lengthCounter=1, lengthToDig do
- -- go forward into the first block
- local p = peripheral.wrap("left")
- p.dig()
- digRight()
- turtle.forward()
- for widthCounter=1, widthToDig do
- heightCounter=1
- -- go up the first column and dig to the right also
- while heightCounter < heightToDig do
- checkIfFull()
- p.dig()
- p.digUp()
- if turtle.up() == false then
- repeat
- p.digUp()
- sleep(1)
- until turtle.up() == true
- end
- heightCounter = heightCounter + 1
- digRight()
- end
- -- we have reached the top of a vertical column so we need to move right by 1
- p.dig()
- turtle.turnRight()
- p.dig()
- turtle.forward()
- --p.dig()
- --turtle.forward()
- turtle.turnLeft()
- heightCounter=1
- -- come back down and dig to the right also
- while heightCounter < heightToDig do
- checkIfFull()
- p.dig()
- p.digDown()
- if turtle.down() == false then
- repeat
- p.digDown()
- sleep(1)
- until turtle.down() == true
- end
- heightCounter = heightCounter + 1
- digRight()
- end
- -- we have reached the bottom of a vertical column so we need to move right by 1 before starting another column
- p.dig()
- turtle.turnRight()
- p.dig()
- turtle.forward()
- --p.dig()
- --turtle.forward()
- turtle.turnLeft()
- end
- -- need to move back to the bottom left and start the new length
- -- come back down and dig to the right also
- turtle.turnLeft()
- for widthCounter=1, (widthToDig*2) +0 do
- digForwardGravel()
- end
- turtle.turnRight()
- digForwardGravel()
- --
- end
- for lengthCounter=1, lengthToDig do
- turtle.back()
- end
- -- move back one more and one up
- turtle.back()
- turtle.up()
- turtle.up()
- end
- main_code()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement