Advertisement
Guest User

mydance2.lua

a guest
Jul 16th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. local isUp = false
  2. local isBack = false
  3. local danceMove
  4. print('Hold Ctrl-T to stop dancing.')
  5. while true do
  6.     danceMove = math.random(1, 5)
  7.    
  8.     if danceMove == 1 then
  9.         -- turn left
  10.         print('Turn to the left!')
  11.         turtle.turnLeft()
  12.        
  13.     elseif danceMove == 2 then
  14.         -- turn right
  15.         print('Turn to the right!')
  16.         turtle.turnRight()
  17.        
  18.     elseif danceMove == 3 then
  19.         -- forward/back moves
  20.         if isBack then
  21.             print('Move forward!')
  22.             turtle.forward()
  23.             isBack = false
  24.         else
  25.             print('Move back!')
  26.             turtle.back()
  27.             isBack = true
  28.         end
  29.        
  30.     elseif danceMove == 4 then
  31.         -- up/down moves
  32.         if isUp then
  33.             print('Get down!')
  34.             turtle.down()
  35.             isUp = false
  36.         else
  37.             print('Get up!')
  38.             turtle.up()
  39.             isUp = true
  40.         end
  41.        
  42.     else
  43.         -- spin around
  44.         print('Spin!')
  45.         for i = 1,4 do
  46.             turtle.turnLeft()
  47.         end
  48.     end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement