D-MO84

PlatformBuilder

Nov 23rd, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  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. -- place a block below turtle till length is reached
  8. function buildForward()
  9.  
  10. for i=1, length do
  11. checkInv()
  12. turtle.placeDown()
  13. turtle.forward()
  14. end
  15. end
  16.  
  17. -- reorient turtle to the right
  18. function spinRight()
  19.  
  20. turtle.turnRight()
  21. turtle.forward()
  22. turtle.turnRight()
  23. turtle.forward()
  24.  
  25. end
  26.  
  27. -- reorient turtle to the left
  28. function spinLeft()
  29.  
  30. turtle.turnLeft()
  31. turtle.forward()
  32. turtle.turnLeft()
  33. turtle.forward()
  34.  
  35. end
  36.  
  37. function checkInv()
  38.  
  39. if turtle.getItemCount( turtle.getSelectedSlot()) == 0 then
  40. turtle.select(turtle.getSelectedSlot() + 1)
  41. elseif turtle.getSelectedSlot() == 16 then
  42. os.shutdown()
  43. end
  44.  
  45. end
  46.  
  47. --Main program loop
  48.  
  49. for j=1,(width - 2) do
  50.  
  51. buildForward()
  52. spinRight()
  53.  
  54. buildForward()
  55. spinLeft()
  56. end
Advertisement
Add Comment
Please, Sign In to add comment