Advertisement
AkaZombie

Area Flattening ComputerCraft

Dec 15th, 2012
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. -- Area Flatten v1.0 by AkaZombie
  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.    if turtle.up() then
  27.     upc = upc + 1
  28.    end
  29.    sleep(0.25)
  30.   until turtle.detectUp() == false
  31.  end
  32.  for dc = 1, upc do
  33.   tfuel(1)
  34.   turtle.down()
  35.  end
  36. end
  37.  
  38. function turnaround()
  39.   turtle.turnRight()
  40.   turtle.turnRight()
  41. end
  42.  
  43. -- Main Script
  44. for i = 1, width do
  45.  for j = 1, togo do
  46.   tfuel(1)
  47.   if turtle.detect() then
  48.    repeat
  49.     turtle.dig()
  50.     sleep(0.5)
  51.    until turtle.detect() == false
  52.    turtle.forward()
  53.    upuntil()
  54.   else
  55.    turtle.forward()
  56.    upuntil()
  57.   end
  58.  end
  59.  turnaround()
  60.  for j = 1, togo do
  61.   tfuel(1)
  62.   turtle.forward()
  63.  end
  64.  turtle.turnLeft()
  65.  if turtle.detect() then
  66.   repeat
  67.    turtle.dig()
  68.    sleep(0.5)
  69.   until turtle.detect() == false
  70.  end
  71.  turtle.forward()
  72.  turtle.turnLeft()
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement