Advertisement
AkaZombie

Down 16

Dec 24th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.88 KB | None | 0 0
  1. -- Digging Down to 16 by AkaZombie
  2.  
  3. -- Vars
  4. local tArgs = { ... }
  5. local curh = tonumber(tArgs[1])
  6. local cw = tArgs[2]
  7. cw = cw or "y"
  8. local dest = 16
  9. local dist = curh - dest
  10. local roomrad = 10
  11. local roomsize = 20
  12. local torch = 1
  13. local stair = 2
  14. local cobble = 3
  15. local fuel = 4
  16.  
  17. --Functions
  18.  
  19. function tfuel(amount)
  20.  if turtle.getFuelLevel() < 5 then
  21.   turtle.select(fuel)
  22.   turtle.refuel(amount)
  23.  end
  24. end
  25.  
  26. function turnaround()
  27.   turtle.turnRight()
  28.   turtle.turnRight()
  29. end
  30.  
  31. function placefront(item)
  32.  turtle.select(item)
  33.  turtle.place()
  34. end
  35.  
  36. function placedown(item)
  37.  turtle.select(item)
  38.  turtle.placeDown()
  39. end
  40.  
  41. function placeup(item)
  42.  turtle.select(item)
  43.  turtle.placeUp()
  44. end
  45.  
  46. function checkwalls()
  47.  if cw == "y" then
  48.   turtle.turnRight()
  49.   if (turtle.detect() == false) then
  50.    placefront(cobble)
  51.   end
  52.   turnaround()
  53.   if (turtle.detect() == false) then
  54.    placefront(cobble)
  55.   end
  56.   turtle.turnRight()
  57.  end
  58. end
  59.  
  60. function checkwallsL()
  61.  if cw == "y" then
  62.   turtle.turnLeft()
  63.   if (turtle.detect() == false) then
  64.    placefront(cobble)
  65.   end
  66.   tfuel(1)
  67.   turtle.down()
  68.   if (turtle.detect() == false) then
  69.    placefront(cobble)
  70.   end
  71.   tfuel(1)
  72.   turtle.up()
  73.   turtle.up()
  74.   if (turtle.detect() == false) then
  75.    placefront(cobble)
  76.   end
  77.   tfuel(1)
  78.   turtle.down()
  79.   turtle.turnRight()
  80.  end
  81. end
  82.  
  83. function digfoward()
  84.  repeat
  85.   turtle.dig()
  86.   sleep(0.5)
  87.  until turtle.detect() == false
  88. end
  89.  
  90. function digup()
  91.  repeat
  92.   turtle.digUp()
  93.   sleep(0.5)
  94.  until turtle.detectUp() == false
  95. end
  96.  
  97.  
  98. -- Main Script
  99. for i = 1, dist do
  100.  tfuel(1)
  101.  turtle.digDown()
  102.  turtle.down()
  103.  digfoward()
  104.  checkwalls()
  105.  if (turtle.detectDown() == false) then
  106.   placedown(cobble)
  107.  end
  108.  tfuel(1)
  109.  turtle.forward()
  110.  turnaround()
  111.  placefront(stair)
  112.  turnaround()
  113.  for j=1, 2 do
  114.   checkwalls()
  115.   digfoward()
  116.   tfuel(1)
  117.   turtle.forward()
  118.  end
  119.  turnaround()
  120.  tfuel(1)
  121.  turtle.forward()
  122.  turtle.forward()
  123.  turnaround()
  124.  if (i % 4 == 0) then
  125.   placeup(torch)
  126.  end
  127. end
  128.  
  129. --Clear Room
  130.  
  131. turtle.turnLeft()
  132. tfuel(1)
  133. turtle.up()
  134. pass = 0
  135. while (roomsize >= 0) do
  136.  for r = 1, roomrad do
  137.   digfoward()
  138.   tfuel(1)
  139.   turtle.forward()
  140.   digup()
  141.   turtle.digDown()
  142.   if (pass == 0) then
  143.    checkwallsL()
  144.   end
  145.  end
  146.  
  147.  for l = 1, 3 do
  148.   turtle.turnRight()
  149.   for r = 1, roomsize do
  150.    digfoward()
  151.    tfuel(1)
  152.    turtle.forward()
  153.    digup()
  154.    turtle.digDown()
  155.   if (pass == 0) then
  156.    checkwallsL()
  157.   end
  158.    if (r % 6 == 0) then
  159.     placedown(torch)
  160.    end
  161.   end
  162.  end
  163.  
  164.  turtle.turnRight()
  165.  for r = 1, roomrad do
  166.   digfoward()
  167.   tfuel(1)
  168.   turtle.forward()
  169.   digup()
  170.   turtle.digDown()
  171.   if (pass == 0) then
  172.    checkwallsL()
  173.   end
  174.  end
  175.  tfuel(1)
  176.  turtle.forward()
  177.  turtle.turnRight()
  178.  digfoward()
  179.  tfuel(1)
  180.  turtle.forward()
  181.  turtle.turnLeft()
  182.  pass = pass + 1
  183.  roomrad = roomrad - 1
  184.  roomsize = roomsize - 2
  185. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement