Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get q4kqxzkx wTunnel
- -- rm wTunnel.lua To update
- function refuelTurtle()
- print("Slot: " .. turtle.getSelectedSlot())
- -- print("Item ID: " .. turtle.getItemDetail()) It's a table
- print("Number of Items: " .. turtle.getItemCount())
- turtle.refuel()
- print("Turtle refueled!")
- end
- function digForward()
- while turtle.detect() do
- print("Digging forward!")
- turtle.dig()
- end
- end
- function digUp()
- while turtle.detectUp() do
- --print("Digging Up!")
- turtle.digUp()
- end
- end
- function digDown()
- while turtle.detectDown() do
- --print("Digging down!")
- turtle.digDown()
- end
- end
- function moveForward()
- if (turtle.detect() == false) then
- print("Moving Forward!")
- turtle.forward()
- else
- print("Block detected in Front!")
- digForward()
- turtle.forward()
- end
- end
- function moveUp()
- if (turtle.detectUp() == false) then
- print("Moving up!")
- turtle.up()
- else
- print("Block detected above!")
- digUp()
- turtle.up()
- end
- end
- function turnRight()
- print("Turning Right!")
- turtle.turnRight()
- --moveForward()
- end
- function turnLeft()
- print("Turning Left!")
- turtle.turnLeft()
- --moveForward()
- end
- function inPosition()
- turtle.forward()
- moveForward()
- digUp()
- moveUp()
- digUp()
- print("We are now in position!")
- end
- function digCenter()
- digForward()
- moveForward()
- digUp()
- digDown()
- end
- -- put this in a function eventually
- -- local input = io.read("*n") io.read() is read() in CC
- print('How many blocks forward do you want to go?')
- local input = read()
- print('Now Mining ' .. input .. ' Blocks forward')
- local input = tonumber(input)
- function digCycle()
- local blocks = 0
- local turtleSlot = 2
- local turtleBottomRightSlot = 15
- while blocks < input do
- -- 1 is top left, 16 bottom right, checks how many items in slot 16
- if (turtle.getItemCount(turtleBottomRightSlot) >= 1) then
- print('Slot ' .. turtle.getSelectedSlot() .. ' has: ' .. turtle.getItemCount(turtleBottomRightSlot))
- -- print('Slot 9 holds: ' .. turtle.getItemDetail(turtleBottomRightSlot))
- -- attempt to concatenate string and table
- -- select chest from bottom right, it was automatically consumed when in slot 1
- turtle.select(16)
- print('Selecting slot ' .. turtle.getSelectedSlot())
- --print('Current slot holds: ' .. turtle.getItemDetail())
- print('Currently Holding:' .. turtle.getItemCount() .. ' items')
- print('Placing down a chest from slot ' .. turtle.getSelectedSlot())
- turtle.placeDown()
- while turtleSlot < turtleBottomRightSlot do
- turtle.select(turtleSlot)
- print('Slot: '.. turtle.getSelectedSlot())
- --print('Item ID: ' .. turtle.getItemDetail())
- print('Amount: ' .. turtle.getItemCount() .. ' items')
- turtle.dropDown()
- turtleSlot = turtleSlot+1
- end
- end
- turnRight() -- Turns doesn't move
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- turnLeft()
- digCenter()
- turnLeft()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- digCenter()
- turnRight()
- digCenter()
- blocks = blocks+1
- print(blocks)
- end
- end
- function returnBack()
- local x = -3
- -- Get in position
- turnRight()
- digCenter()
- digCenter()
- turnRight()
- while x < input do
- turtle.forward()
- x = x + 1
- end
- turnRight()
- turtle.forward()
- turtle.forward()
- turnRight()
- end
- refuelTurtle()
- inPosition()
- digCycle()
- returnBack()
- print("Cycle Complete!")
Add Comment
Please, Sign In to add comment