Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- donedistance = 0
- leftdistance = 0
- totaldistance = 0
- doneblocks = 0
- leftblocks = 0
- totalblocks = 0
- torchblocks = 0
- status = false
- height = 0
- width = 0
- function input()
- term.clear()
- term.setTextColor(colors.blue)
- term.setCursorPos(1, 1)
- term.write("Input tunnel width: ")
- temp = read()
- if tonumber(temp) == nil then
- input()
- else
- width = tonumber(temp)
- term.clear()
- term.setTextColor(colors.blue)
- term.setCursorPos(1, 1)
- term.write("Input tunnel height: ")
- temp = read()
- if tonumber(temp) == nil then
- input()
- else
- height = tonumber(temp)
- term.clear()
- term.setTextColor(colors.blue)
- term.setCursorPos(1, 1)
- term.write("Input tunnel distance: ")
- temp = read()
- if tonumber(temp) == nil then
- input()
- else
- totaldistance = tonumber(temp)
- totalblocks = height * width * totaldistance
- tunnel()
- end
- end
- end
- end
- function update()
- term.clear()
- term.setTextColor(colors.red)
- term.setCursorPos(1, 1)
- term.write("Total distance : " .. totaldistance)
- term.setCursorPos(1, 2)
- term.write("Distance done : " .. donedistance)
- term.setCursorPos(1, 3)
- term.write("Distance left : " .. leftdistance)
- term.setCursorPos(1, 4)
- term.write("Total blocks : " .. totalblocks)
- term.setCursorPos(1, 5)
- term.write("Blocks done : " .. doneblocks)
- term.setCursorPos(1, 6)
- term.write("Blocks left : " .. leftblocks)
- term.setCursorPos(1, 7)
- term.write("Next torch : " .. (12 - torchblocks))
- term.setCursorPos(1, 8)
- if status == true then
- term.setTextColor(colours.green)
- term.write("Status : Finished")
- else
- term.setTextColor(colours.red)
- term.write("Status : Unfinished")
- end
- end
- function drop()
- right(2)
- for i = 1, donedistance do
- turtle.forward()
- end
- for i = 2, 15 do
- turtle.select(i)
- turtle.drop()
- end
- if status == false then
- right(2)
- for i = 1, donedistance do
- turtle.forward()
- end
- end
- end
- function move(direction)
- if direction == "for" then
- repeat
- turtle.dig()
- sleep(0.2)
- until turtle.forward() == true
- doneblocks = doneblocks + 1
- leftblocks = totalblocks - doneblocks
- update()
- elseif direction == "up" then
- repeat
- turtle.digUp()
- sleep(0.2)
- until turtle.up() == true
- doneblocks = doneblocks + 1
- leftblocks = totalblocks - doneblocks
- update()
- elseif direction == "dow" then
- repeat
- turtle.digDown()
- sleep(0.2)
- until turtle.down() == true
- doneblocks = doneblocks + 1
- leftblocks = totalblocks - doneblocks
- update()
- end
- end
- function left(amount)
- for i = 1, amount do
- turtle.turnLeft()
- end
- end
- function right(amount)
- for i = 1, amount do
- turtle.turnRight()
- end
- end
- function strip(width, height)
- halfwidth = math.floor(width / 2)
- move("for")
- for i = 1, height do
- left(1)
- for ii = 1, halfwidth do
- move("for")
- if i == 1 then
- turtle.select(1)
- turtle.placeDown()
- elseif i == height then
- turtle.select(1)
- turtle.placeUp()
- end
- end
- turtle.select(1)
- turtle.place()
- turtle.back()
- if i == 1 then
- if torchblocks == 12 then
- turtle.select(16)
- turtle.place()
- turtle.select(1)
- torchblocks = 0
- end
- end
- right(2)
- for ii = 1, (halfwidth - 1) do
- turtle.forward()
- end
- for ii = 1, halfwidth do
- move("for")
- if i == 1 then
- turtle.select(1)
- turtle.placeDown()
- elseif i == height then
- turtle.select(1)
- turtle.placeUp()
- end
- end
- turtle.select(1)
- turtle.place()
- turtle.back()
- if i == 1 then
- if torchblocks == 12 then
- turtle.select(16)
- turtle.place()
- turtle.select(1)
- torchblocks = 0
- end
- end
- left(2)
- for ii = 1, (halfwidth - 1) do
- turtle.forward()
- end
- right(1)
- move("up")
- end
- for i = 1, (height - 1) do
- turtle.down()
- end
- if turtle.getItemCount(15) > 0 then
- drop()
- end
- end
- function tunnel()
- for i = 1, totaldistance do
- strip(width, height)
- donedistance = donedistance + 1
- leftdistance = totaldistance + donedistance
- torchblocks = torchblocks + 1
- update()
- end
- status = true
- update()
- end
- input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement