Guest User

Untitled

a guest
Jul 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. local tArgs = { ... }
  2. if #tArgs ~= 1 then
  3. print("Usage: putvuller <maxBlocks>")
  4. return
  5. end
  6. maxMoves = tonumber(tArgs[1])
  7. moves = 0
  8. print("Putvuller activated for #" .. maxMoves .. " blocks")
  9. curSlot = 1
  10. turtle.select(curSlot)
  11. stop = false
  12.  
  13. function checkSlot()
  14. if turtle.getItemCount(curSlot) < 1 then
  15. curSlot = curSlot + 1
  16. if curSlot > 9 then
  17. stop = true
  18. return
  19. end
  20. turtle.select(curSlot)
  21. checkSlot()
  22. end
  23. end
  24.  
  25. function buildAndMove()
  26. local worked = turtle.place()
  27. if worked then
  28. moves = moves + 1
  29. end
  30. output = turtle.back()
  31. return output
  32. end
  33.  
  34. function determineNextMove()
  35. if canMove() then
  36. return true
  37. end
  38. turtle.turnLeft()
  39. if canMove() then
  40. return true
  41. end
  42. turtle.turnRight()
  43. turtle.turnRight()
  44. if canMove() then
  45. return true
  46. end
  47. stop = true
  48. return false
  49. end
  50.  
  51. function canMove()
  52. local succ = turtle.back()
  53. if succ then
  54. turtle.forward()
  55. return true
  56. end
  57. return false
  58. end
  59.  
  60. while not stop and moves < maxMoves do
  61. checkSlot()
  62. if determineNextMove() then
  63. buildAndMove()
  64. end
  65. end
  66. print("Gedaan met putvullen...")
Add Comment
Please, Sign In to add comment