Jharakn

roof builder

Apr 19th, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. --turtle builder
  2. function stopForBricks() --halts the turtle if its out of bricks pending a refill
  3. print("out of bricks, fill'er up and press c")
  4. while true do
  5. local event, character = os.pullEvent()
  6. if event == "char" and character == "c" then break end
  7. end
  8. end
  9.  
  10. --main program
  11. local slotNum = 1
  12.  
  13. local sides = 1
  14.  
  15. print("length?")
  16. local length = tonumber(read())
  17.  
  18. while length > 5 do
  19. for i = 1,length do
  20. if turtle.getItemCount(slotNum) == 0 then
  21. slotNum = slotNum + 1
  22. if slotNum == 17 then
  23. stopForBricks()
  24. slotNum = 1
  25. end
  26. end
  27. turtle.select(slotNum)
  28. turtle.placeDown()
  29. turtle.forward()
  30. end
  31.  
  32. turtle.turnRight()
  33. sides = sides + 1
  34.  
  35. if side == 5 then
  36. turtle.turnRight()
  37. turtle.forward()
  38. turtle.turnLeft()
  39. turtle.forward()
  40. length = length - 2
  41. elseif side == 9 then
  42. turtle.up()
  43. side = 1
  44. end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment