Johndorian

finished

May 12th, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. -- Temporary refuel
  2. turtle.refuel()
  3.  
  4. level = 1       -- Current level    1 - 9
  5. row = 1         -- Current row      1 - 5
  6. block  = 1      -- Current Block    1 - 5
  7. direction = 1   -- For orientation
  8.  
  9. ----- Movement functions ---------
  10.  
  11. function forward()
  12.     while not turtle.forward() do
  13.             turtle.dig()
  14.     end
  15.            
  16. end
  17.    
  18.  
  19.  
  20. function turnLeft()
  21.     turtle.turnLeft()
  22.     forward()
  23.     turtle.turnLeft()
  24. end
  25.  
  26. function turnRight()
  27.     turtle.turnRight()
  28.     forward()
  29.     turtle.turnRight()
  30. end
  31.  
  32. function goDown()
  33.     while not turtle.down() do
  34.             turtle.digDown()
  35.     end
  36.    
  37.         if level == 1 or 3 or 5 or 7 or 9 then
  38.                         turtle.turnRight()
  39.                         turtle.turnRight()
  40.                             else
  41.                                 turtle.turnLeft()
  42.                                 turtle.turnLeft()
  43.         end
  44.     row = 1
  45.     level = level + 1
  46. end
  47.  
  48. -------------------------------
  49.  
  50. function platform()
  51.         for row = 1,4 do
  52.         digLine()
  53.         orientation()
  54.         end
  55.             if level < 9 and row == 5 then
  56.                 digLine()
  57.                 goDown()
  58.             end
  59. end
  60.  
  61.  
  62. function orientation()
  63.     if direction == 1 then
  64.         turnRight()
  65.         direction = 0
  66.             elseif direction == 0 then
  67.                 turnLeft()
  68.                 direction = 1
  69.     end
  70. end
  71.    
  72.  
  73. function digLine()
  74.     while block <= 5 do
  75.         forward()
  76.         block = block + 1
  77.     end
  78.     block = 1
  79.     row = row + 1
  80. end
  81.  
  82. function initial()
  83.     repeat
  84.     platform()
  85.     until level >= 9
  86.     shell.run("info.lua")
  87. end
  88.  
  89. initial()
Advertisement
Add Comment
Please, Sign In to add comment