Advertisement
Guest User

startup

a guest
Sep 2nd, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. local x=0
  2. local y=0
  3. local z=0
  4.  
  5. local targx
  6. local targy
  7. local targz
  8.  
  9. --local sides = {"left","front","right","back"}
  10.  
  11. modem = peripheral.wrap("right")
  12.  
  13. modem.open(1)
  14. modem.open(2)
  15.  
  16. if modem.isOpen(1) ~= true then
  17.   print("Modem cannot open on channel 1")
  18.   error()
  19. end
  20.  
  21. if modem.isOpen(2) ~= true then
  22.   print("Modem cannot open on channel 2")
  23.   error()
  24. end
  25.  
  26. modem.transmit(1,2,"Turtle's Modem is alive")
  27.  
  28. print("Insert how many blocks to dig in the X direction")
  29. targx=tonumber(read())
  30. print("Insert how many blocks to dig in the Y direction")
  31. targy=tonumber(read())
  32. print("Insert how many blocks to dig in the Z direction")
  33. targz=tonumber(read())
  34.  
  35. print("The desired hole is " ..targx "x" ..targy "x" ..targz " in size")
  36. print("Place the turtle on the BOTTOM RIGHT corner of the area you want to dig")
  37. print("Then place a redstone torch behind the turtle. The turtle will face the correct direction automatically")
  38.  
  39. print("Press any key when torch is placed")
  40. read()
  41. while redstone.getInput("back")~=true do
  42.   turtle.turnLeft()
  43. end
  44.  
  45. if turtle.getFuelLevel()<64 then
  46.   print("Place fuel on the first turtle slot")
  47.   while turtle.refuel() == false do
  48.     turtle.refuel()
  49.     os.sleep(1)
  50.   end
  51. end
  52.  
  53. print("Press enter to start")
  54. read()
  55. print("Starting in 5 seconds")
  56. modem.transmit(1,2,"Starting in 5 seconds")
  57. os.sleep(5)
  58. modem.transmit(1,2,"Starting")
  59.  
  60. for x=0,targx-1,1 do
  61.   for y=0,targy-1,1 do
  62.     for z=0,targz-1,1 do
  63.       modem.transmit(1,2,z)
  64.       turtle.dig()
  65.       modem.transmit(1,2,"Dig")
  66.       if z~= (targz-1) then
  67.         turtle.forward()
  68.       end
  69.     end
  70.     for z=targy-1,0,-1 do
  71.       turtle.back()
  72.       modem.transmit(1,2,z)
  73.     end
  74.     if y~=(targy-1) then
  75.       turtle.turnLeft()
  76.       turtle.forward()
  77.       turtle.turnRight()  
  78.     end
  79.   end
  80.   turtle.turnLeft()
  81.   for y=targy-1,0,-1 do
  82.     turtle.back()
  83.     modem.transmit(1,2,y)
  84.   end
  85.   turtle.turnRight()
  86.   if x~=(targx-1) then
  87.     turtle.up()
  88.   end
  89. end
  90. for x=targx-1,0,-1 do
  91.   turtle.down()
  92. end
  93. modem.transmit(1,2,"Done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement