Advertisement
kpvw

tunnelPlus

Dec 16th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local tArgs = {...}
  2.  
  3. toGo = tonumber tArgs[1]
  4. blocksDug = 0
  5. blocksPlaced = 0
  6. torchesPlaced = 0
  7. term.clear()
  8. term.setCursorPos(1, 1)
  9.  
  10. function tunnel(dist)
  11.  for i=1, dist do
  12.   if turtle.dig() then
  13.    blocksDug += 1
  14.   end
  15.   turtle.digUp()
  16.   turtle.forward()
  17.  
  18.   if turtle.detectDown() then
  19.    if turtle.placeDown() then
  20.     blocksPlaced += 1
  21.    end
  22.   end  
  23.   if i % 10 == 0 then
  24.    turtle.select(16)
  25.    if turtle.placeUp() then
  26.     torchesPlaced += 1
  27.    end
  28.    turtle.select(1)
  29.  end
  30.  return "done"
  31. end
  32.  
  33. while not tunnel(toGo) == "done" do
  34.  term.clear()
  35.  term.setCursorPos(1, 1)
  36.  term.write("Digging a tunnel "..tostring(toGo).." blocks long.")
  37.  term.setCursorPos(1, 2)
  38.  term.write("Blocks dug: "..tostring(blocksDug))
  39.  term.setCursorPos(1, 3)
  40.  term.write("Blocks placed(for bridges): "..tostring(blocksPlaced))
  41.  term.setCursorPos(1, 4)
  42.  term.write("Torches placed: "..tostring(torchesPlaced))
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement