DorianH935

Untitled

Jun 24th, 2024
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. -- control.lua
  2. -- Program to control a turtle using W, A, S, D, Space, and Shift keys
  3.  
  4. local function moveTurtle()
  5. while true do
  6. local event, key = os.pullEvent("key")
  7.  
  8. if key == keys.w then
  9. turtle.forward()
  10. elseif key == keys.a then
  11. turtle.turnLeft()
  12. turtle.forward()
  13. turtle.turnRight()
  14. elseif key == keys.s then
  15. turtle.back()
  16. elseif key == keys.d then
  17. turtle.turnRight()
  18. turtle.forward()
  19. turtle.turnLeft()
  20. elseif key == keys.space then
  21. turtle.up()
  22. elseif key == keys.leftShift then
  23. turtle.down()
  24. end
  25. end
  26. end
  27.  
  28. -- Start the turtle control program
  29. print("Control the turtle with W, A, S, D, Space, and Shift keys.")
  30. moveTurtle()
  31.  
Advertisement
Add Comment
Please, Sign In to add comment