Advertisement
D-MO84

PlatformBuilderV2

Nov 24th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Input Variabls for length and width of platform
  2. local inVars = {...}
  3.  
  4. local width = tonumber(inVars[1])
  5. local length = tonumber(inVars[2])
  6.  
  7. local widthCount = tonumber(0)
  8.  
  9. -- place a block below turtle till length is reached
  10. function buildForward()
  11.  
  12. for i=1, length do
  13. checkInv()
  14. turtle.placeDown()
  15. turtle.forward()
  16. end
  17. end
  18.  
  19. -- reorient turtle to the right
  20. function spinRight()
  21.  
  22. turtle.turnRight()
  23. turtle.forward()
  24. turtle.turnRight()
  25. turtle.forward()
  26.  
  27. end
  28.  
  29. -- reorient turtle to the left
  30. function spinLeft()
  31.  
  32. turtle.turnLeft()
  33. turtle.forward()
  34. turtle.turnLeft()
  35. turtle.forward()
  36.  
  37. end
  38.  
  39. function checkInv()
  40.  
  41. if turtle.getItemCount( turtle.getSelectedSlot()) == 0 then
  42. turtle.select(turtle.getSelectedSlot() + 1)
  43. elseif turtle.getSelectedSlot() == 16 then
  44. os.shutdown()
  45. end
  46.  
  47. end
  48.  
  49. --Main program loop
  50.  
  51. while true do
  52.  
  53. buildForward()
  54. spinRight()
  55. widthCount = widthCount + 1
  56. if widthCount == width then
  57. break
  58. end
  59. buildForward()
  60. spinLeft()
  61. widthCount = widthCount + 1
  62. if widthCount == width then
  63. break
  64. end
  65.  
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement