Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function start()
- -- 1 = Height | 2 = Length | 3 = Rows | 4 = Rows before dump
- local input = get_input()
- local next_dump = input[4]
- local current_row = 1
- for r = 1, input[3] do
- term.clear()
- print("Digging line " .. r .. "...")
- dig_line(input[2], input[1])
- if r < input[3] then
- next_row(input[1])
- end
- if r == next_dump and r ~= input[3] then
- next_dump = next_dump + input[4]
- term.clear()
- print("Dumping storage...")
- reset_row(r)
- dump_storage()
- return_to_row(r)
- end
- current_row = r
- end
- reset_row(current_row - 1)
- dump_storage()
- end
- function dump_storage()
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function return_to_row(rows)
- turtle.turnLeft()
- for r = 1, rows do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- turtle.turnRight()
- end
- function reset_row(current_row)
- turtle.turnRight()
- for r = 1, current_row do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- turtle.turnLeft()
- end
- function get_input()
- term.clear()
- io.write("Line starts on the next block from the turtle.")
- io.write("Chest needs to be behind the turtle.")
- io.write("The turtle mines from right to left.")
- io.write("Enter to continue...")
- io.read()
- term.clear()
- io.write("Enter height: ")
- local height = tonumber(io.read())
- term.clear()
- io.write("Enter length: ")
- local length = tonumber(io.read())
- term.clear()
- io.write("Enter rows: ")
- local rows = tonumber(io.read())
- term.clear()
- io.write("Enter storage dumped (rows): ")
- local rows_before_dump = tonumber(io.read())
- term.clear()
- return { height, length, rows, rows_before_dump }
- end
- function dig_line(length, height)
- -- Start next line.
- for l = 1, length do
- while not turtle.forward() do
- turtle.dig()
- end
- -- Dig up till max. height.
- for h = 1, height do
- while not turtle.up() do
- turtle.digUp()
- end
- end
- -- reset height.
- for h = 1, height do
- while not turtle.down() do
- turtle.digDown()
- end
- end
- end
- reset_length(length)
- end
- function reset_length(length)
- turtle.turnLeft()
- turtle.turnLeft()
- for l = 1, length do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function next_row(height)
- turtle.turnLeft()
- while not turtle.forward() do
- turtle.dig()
- end
- -- Dig up till max. height.
- for h = 1, height do
- while not turtle.up() do
- turtle.digUp()
- end
- end
- -- reset height.
- for h = 1, height do
- while not turtle.down() do
- turtle.digDown()
- end
- end
- turtle.turnRight()
- end
- start()
Advertisement
Comments
-
- New version of my mining script for ComputerCraft.
- Chest needs to be behind the turtle.
- The turtle mines from right to left.
Add Comment
Please, Sign In to add comment
Advertisement