Advertisement
Guest User

flat

a guest
Mar 17th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. -- Area Flatten Script 1.0 by oneupe1even of OmegaTEK Industries on the OniTech server
  2.  
  3. -- Variables
  4.  
  5. local tArgs = {...}
  6.  
  7. if #tArgs == 0 then
  8.   print("Usage: flat [length] [width]")
  9.   return
  10. else
  11.   local length = tonumber(tArgs[1])
  12.   local width = tonumber(tArgs[2])  
  13. end
  14.  
  15. local turnFlag = true
  16.  
  17. -- Functions
  18.  
  19. local function tFuel(amount) -- By Guude
  20.   if turtle.getFuelLevel() < 5 then
  21.     turtle.select(16)
  22.     turtle.refuel(amount)
  23.     turtle.select(1)
  24.   end
  25. end
  26.  
  27. local function digMove()
  28.   if turtle.detect() then
  29.     repeat
  30.       turtle.dig()
  31.       sleep(.25)
  32.     until turtle.detect() == false
  33.     tFuel(1)
  34.     turtle.forward()
  35.   else
  36.     tFuel(1)
  37.     turtle.forward()
  38.   end
  39. end
  40.  
  41. local function checkTop()
  42.   if turtle.detectUp() then
  43.     repeat
  44.       tFuel(1)
  45.       repeat
  46.         turtle.digUp()
  47.         sleep(.25)
  48.       until turtle.detectUp() == false
  49.       turtle.up()
  50.     until turtle.detectUp() == false
  51.     repeat
  52.       tFuel(1)
  53.       turtle.down()
  54.     until turtle.detectDown()
  55.   end
  56. end
  57.  
  58. local function uTurn()
  59.   for i = 1, 2 do
  60.     turtle.turnRight()
  61.   end
  62. end
  63.  
  64. local function mineLine()
  65.   for i = 1, length do
  66.     tFuel()
  67.     digMove()
  68.     checkTop()
  69.   end
  70. end
  71.  
  72. -- Main Script
  73.  
  74. for i = 1, width do
  75.   mineLine()
  76.   if turnFlag then
  77.     turtle.turnRight()
  78.     digMove()
  79.     turtle.turnRight()
  80.     turnFlag = false
  81.   else
  82.     turtle.turnLeft()
  83.     digMove()
  84.     turtle.turnLeft()
  85.     turnFlag = true
  86.   end
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement