Advertisement
1lann

tmine

Jun 23rd, 2012
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 KB | None | 0 0
  1. function dig()
  2. steps = userside-1
  3. while steps > 0 do
  4. turtle.dig()
  5. turtle.forward()
  6. steps = steps-1
  7. storage = turtle.getItemCount(2)
  8. if storage > 60 then
  9. turtle.select(2)
  10. turtle.drop(storage-15)
  11. end
  12. storage = turtle.getItemCount(3)
  13. if storage > 60 then
  14. turtle.select(3)
  15. turtle.drop(storage-2)
  16. end
  17. if fourth == true then
  18. storage = turtle.getItemCount(4)
  19. if storage > 60 then
  20. turtle.select(4)
  21. turtle.drop(storage-2)
  22. end
  23. end
  24. turtle.select(1)
  25. end
  26. steps = userside-1
  27. end
  28.  
  29. function turn(turn)
  30. if turn == "left" then
  31. turn = "right"
  32. turtle.turnRight()
  33. turtle.dig()
  34. turtle.forward()
  35. turtle.turnRight()
  36. return turn
  37. elseif turn == "right" then
  38. turn = "left"
  39. turtle.turnLeft()
  40. turtle.dig()
  41. turtle.forward()
  42. turtle.turnLeft()
  43. return turn
  44. end
  45. end
  46.  
  47. function lastaction()
  48. dig()
  49. turtle.digDown()
  50. turtle.down()
  51. turtle.turnRight()
  52. turtle.turnRight()
  53. end
  54.  
  55. function ladderfinished()
  56. height = userheight
  57. turtle.select(1)
  58. while height > 0 do
  59. turtle.down()
  60. turtle.place()
  61. height = height-1
  62. end
  63. turtle.dig()
  64. turtle.forward()
  65. turtle.turnRight()
  66. turtle.turnRight()
  67. os.shutdown()
  68. end
  69.  
  70.  
  71. function ladders()
  72. dig()
  73. height = userheight
  74. turtle.select(2)
  75. while height > 0 do
  76. if turtle.detect() then
  77. turtle.up()
  78. if turtle.detectUp() then
  79. turtle.back()
  80. turtle.select(1)
  81. turtle.place()
  82. ladderfinished()
  83. end
  84. else
  85. turtle.place()
  86. turtle.up()
  87. end
  88. height = height-1
  89. end
  90. turtle.back()
  91. ladderfinished()
  92. end
  93.  
  94. print "Excavating..."
  95. turtle.select(1)
  96. userside = 6
  97. userheight = 10
  98. fourth = false
  99. if (userheight % 2) ~= 0 then
  100. userheight = userheight+1
  101. end
  102. steps = userside-1
  103. lastturn = "left"
  104. height = userheight
  105. firsttime = true
  106. while height > 0 do
  107. if firsttime == false then lastaction() end
  108. firsttime = false
  109. col = userside-1
  110. while col > 0 do
  111. dig()
  112. lastturn = turn(lastturn)
  113. col = col-1
  114. end
  115. height = height-1
  116. end
  117. ladders()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement