svennp

turtle platform

Aug 12th, 2012
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. if not turtle then return print "LOL, how are you going to use this program without a turtle?!?" end
  2.  
  3.  
  4. print "how long platform?"
  5. longplat = read()
  6. print "how wide platform?"
  7. wideplat = read()
  8. print "what way to turn first? ( right - left )"
  9. firstturn = read()
  10. print "how many layers?"
  11. layers = read()
  12.  
  13.  
  14. first = true
  15.  
  16.  
  17. if firstturn == "right" or firstturn == "left" then nextturn = firstturn
  18. else return print "Error with first turn!"
  19. end
  20.  
  21.  
  22. function gotoStart()
  23.     longplat2 = longplat - 2
  24.     wideplat2 = wideplat - 2
  25.     turtle.turnLeft()
  26.     turtle.turnLeft()
  27.     for n1 = 0,longplat2 do
  28.         turtle.forward()
  29.     end
  30.     if nextturn == "left" then
  31.         turtle.turnLeft()
  32.     else turtle.turnRight()
  33.     end
  34.     for n1 = 0,wideplat2 do
  35.         turtle.forward()
  36.     end
  37.     if nextturn == "left" then
  38.         turtle.turnLeft()
  39.     else turtle.turnRight()
  40.     end
  41. end
  42.  
  43.  
  44. function layer()
  45.  
  46.     while true do
  47.         if first == true then
  48.             first = false
  49.             longplat1 = longplat
  50.             wideplat1 = wideplat
  51.             longplat1 = longplat1 - 1
  52.         end
  53.         wideplat1 = wideplat1 - 1
  54.         for n1 = 1,longplat1 do
  55.             turtle.placeDown()
  56.             turtle.forward()
  57.             turtle.placeDown()
  58.         end
  59.         if wideplat1 == 0 then break end
  60.         if nextturn == "left" then
  61.             nextturn = "right"
  62.             turtle.turnLeft()
  63.             turtle.forward()
  64.             turtle.turnLeft()
  65.         elseif nextturn == "right" then
  66.             nextturn = "left"
  67.             turtle.turnRight()
  68.             turtle.forward()
  69.             turtle.turnRight()
  70.         end
  71.         turtle.placeDown()
  72.     end
  73.  
  74.  
  75. end
  76.  
  77.  
  78. for n2 = 1,layers do
  79. turtle.up()
  80. layer()
  81. gotoStart()
  82. first = true
  83. end
  84. turtle.down()
Advertisement
Add Comment
Please, Sign In to add comment