jcoutie

skyscraper farm operation

Jan 22nd, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.58 KB | None | 0 0
  1. -- Variables
  2.  
  3. turtle.select(1)
  4. height = 0
  5. local tArgs = { ... }
  6. local levelAlt = tonumber(tArgs[1])
  7.  
  8. -- Functions
  9.  
  10. local function tMove(distance)
  11.   for i=1,distance do
  12.     while turtle.forward() == false do
  13.       turtle.dig()
  14.       turtle.attack()
  15.       sleep(0.5)
  16.     end
  17.   end
  18. end
  19.  
  20. local function tDescend(distance)
  21.   for i=1,distance do
  22.     while turtle.down() == false do
  23.       turtle.digDown()
  24.       turtle.attackDown()
  25.       sleep(0.5)
  26.     end
  27.   end
  28. end
  29.  
  30. local function tAscend(distance)
  31.   for i=1,distance do
  32.     while turtle.up() == false do
  33.       turtle.digUp()
  34.       turtle.attackUp()
  35.       sleep(0.5)
  36.     end
  37.   end
  38. end
  39.  
  40. local function turnaround()
  41.   turtle.turnRight()
  42.   turtle.turnRight()
  43. end
  44.  
  45. local function tPlace()
  46.     turtle.digDown()
  47.   placedItem = 0
  48.   for i=1,2 do
  49.     if turtle.getItemCount(i) > 0 then
  50.       if placedItem == 0 then
  51.         turtle.select(i)
  52.         turtle.placeDown()
  53.         placedItem = 1
  54.       end
  55.     end
  56.   end
  57.   turtle.select(1)
  58. end
  59.  
  60. local function tLineDraw(length)
  61.   for i=1,length do
  62.     tMove(1)
  63.     tPlace()
  64.   end
  65. end
  66.  
  67. local function layCrop()
  68.  turtle.turnLeft()
  69.  tMove(4)
  70.  turnaround()
  71.   tPlace()
  72.  -- Row 1
  73.   tLineDraw(8)
  74.   turtle.turnLeft()
  75.   tLineDraw(1)
  76.   turtle.turnLeft()
  77.  -- Row 2
  78.   tLineDraw(8)
  79.   turtle.turnRight()
  80.   tLineDraw(1)
  81.   turtle.turnRight()
  82.  -- Row 3
  83.   tLineDraw(8)
  84.   turtle.turnLeft()
  85.   tLineDraw(1)
  86.   turtle.turnLeft()
  87.  -- Row 4
  88.   tLineDraw(8)
  89.   turtle.turnRight()
  90.   tLineDraw(1)
  91.   turtle.turnRight()
  92.  -- Row 5 (Centre Block)
  93.   tLineDraw(3)
  94.   turtle.turnRight()
  95.   tMove(1)
  96.   turtle.turnLeft()
  97.   tMove(2)
  98.   turtle.turnLeft()
  99.   tMove(1)
  100.   turtle.turnRight()
  101.   tPlace()
  102.   tLineDraw(3)
  103.   turtle.turnLeft()
  104.   tLineDraw(1)
  105.   turtle.turnLeft()
  106.  -- Row 6
  107.   tLineDraw(8)
  108.   turtle.turnRight()
  109.   tLineDraw(1)
  110.   turtle.turnRight()
  111.  -- Row 7
  112.   tLineDraw(8)
  113.   turtle.turnLeft()
  114.   tLineDraw(1)
  115.   turtle.turnLeft()
  116.  -- Row 8
  117.   tLineDraw(8)
  118.   turtle.turnRight()
  119.   tLineDraw(1)
  120.   turtle.turnRight()
  121.  -- Row 9
  122.   tLineDraw(8)
  123.   turtle.turnRight()
  124.   tMove(8)
  125.  -- Return to Door
  126.   turtle.turnRight()
  127.   tMove(4)
  128.   turtle.turnLeft()
  129.   tMove(2)
  130. end
  131.  
  132. -- Startup
  133.  
  134.  term.clear()
  135.  term.setCursorPos(1,1)
  136.  print("Please place blocks as follows:")
  137.  print("Slot 1 and 2 - Seeds")
  138.  print()
  139.  print("Ground Level = 0")
  140.  print("Press enter a level when ready:")
  141.  level = read(input)
  142.  
  143. -- Main Program
  144. tAscend(4*level + 1)
  145. tMove(2)
  146. layCrop()
  147. tDescend(4*level + 1)
  148. turnaround()
  149. for i=3,16 do
  150.   turtle.select(i)
  151.   turtle.dropDown()
  152. end
  153. turtle.select(1)
Advertisement
Add Comment
Please, Sign In to add comment