Guest User

flat2

a guest
Feb 6th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. -- Area Flatten v1.0 by Guude
  2.  
  3. -- Vars
  4. local tArgs = { ... }
  5. local togo = tonumber(tArgs[1])
  6. local width = tonumber(tArgs[2])
  7. togo = togo or 1
  8. width = width or togo
  9.  
  10.  
  11. -- Functions
  12. function tfuel(amount)
  13.  if turtle.getFuelLevel() < 5 then
  14.   turtle.select(16)
  15.   turtle.refuel(amount)
  16.   turtle.select(1)
  17.  end
  18. end
  19.  
  20. function upuntil()
  21.  local upc = 0
  22.  for u = 1, 5 do
  23.   repeat
  24.    tfuel(1)
  25.    turtle.digUp()
  26.    turtle.dig()
  27.    if turtle.up() then
  28.     upc = upc + 1
  29.    end
  30.    sleep(0.25)
  31.   until turtle.detectUp() == false
  32.  end
  33.  for dc = 1, upc do
  34.   tfuel(1)
  35.   turtle.down()
  36.  end
  37. end
  38.  
  39. function turnaround()
  40.   turtle.turnRight()
  41.   turtle.turnRight()
  42. end
  43.  
  44. -- Main Script
  45. for i = 1, width do
  46.  for j = 1, togo do
  47.   tfuel(1)
  48.   if turtle.detect() then
  49.    repeat
  50.     turtle.dig()
  51.     sleep(0.5)
  52.    until turtle.detect() == false
  53.    turtle.forward()
  54.    upuntil()
  55.   else
  56.    turtle.forward()
  57.    upuntil()
  58.   end
  59.  end
  60.  turnaround()
  61.  for j = 1, togo do
  62.   tfuel(1)
  63.   turtle.forward()
  64.  end
  65.  turtle.turnLeft()
  66.  if turtle.detect() then
  67.   repeat
  68.    turtle.dig()
  69.    sleep(0.5)
  70.   until turtle.detect() == false
  71.  end
  72.  turtle.forward()
  73.  turtle.turnLeft()
  74. end
Advertisement
Add Comment
Please, Sign In to add comment