Advertisement
jcoutie

skyscraper farm installer

Jan 22nd, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.18 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.   if turtle.detectDown() == true then
  47.     turtle.digDown()
  48.   end
  49.   placedItem = 0
  50.   for i=1,2 do
  51.     if turtle.getItemCount(i) > 0 then
  52.       if placedItem == 0 then
  53.         turtle.select(i)
  54.         turtle.placeDown()
  55.         placedItem = 1
  56.       end
  57.     end
  58.   end
  59.   turtle.select(1)
  60. end
  61.  
  62. local function tLineDraw(length)
  63.   for i=1,length do
  64.     tMove(1)
  65.     tPlace()
  66.   end
  67. end
  68.  
  69. local function layDirt()
  70.  turtle.turnLeft()
  71.  tMove(4)
  72.  turnaround()
  73.  for j=1,4 do
  74.   tPlace()
  75.   tLineDraw(8)
  76.   turtle.turnLeft()
  77.   tLineDraw(1)
  78.   turtle.turnLeft()
  79.   tLineDraw(8)
  80.   turtle.turnRight()
  81.   tMove(1)
  82.   turtle.turnRight()
  83.  end
  84.  tPlace()
  85.  tLineDraw(8)
  86.  turnaround()
  87.  tMove(4)
  88.  turtle.turnLeft()
  89.  tMove(4)
  90.  turtle.digDown()
  91.  turtle.select(3)
  92.  turtle.placeDown()
  93.  turtle.select(1)
  94.  tAscend(1)
  95.  turtle.placeDown()
  96.  turtle.turnRight()
  97.  tMove(5)
  98.  turnaround()
  99.  tMove(5)
  100.  turtle.turnRight()
  101.  tMove(1)
  102.  turnaround()
  103.  turtle.select(16)
  104.  turtle.place()
  105.  tDescend(1)
  106.  turtle.select(1)
  107.  turnaround()
  108.  tMove(5)
  109. end
  110.  
  111. -- Startup
  112.  
  113.  term.clear()
  114.  term.setCursorPos(1,1)
  115.  print("Please place blocks as follows:")
  116.  print("Slot 1 and 2 - Dirt")
  117.  print("Slot 3 - Water Bucket")
  118.  print("Slot 16 - Torches (4)")
  119.  print()
  120.  print("Ground Level = 0")
  121.  print("Press enter a level when ready:")
  122.  level = read(input)
  123.  
  124. -- Main Program
  125. tAscend(4*level)
  126. tMove(2)
  127. layDirt()
  128. tDescend(4*level)
  129. turnaround()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement