originalceebs

[MISC] Await movement loop

Jan 9th, 2021 (edited)
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. while true do
  2. local splitString = {}
  3. print("Please enter a command: forward <times>, turnLeft <times> or turnRight <times>")
  4. local userInput = io.read()
  5.  
  6. for i in string.gmatch(userInput, "%S+") do
  7. table.insert(splitString, i)
  8. end
  9.  
  10. if #splitString ~= 2 then
  11. print("Please use forward <times>, turnLeft <times> or turnRight <times>")
  12. end
  13.  
  14. if splitString[1] == "forward" then
  15. moveForward(splitString[2])
  16. elseif splitString[1] == "turnleft" then
  17. turnLeft(splitString[2])
  18. elseif splitString[1] == "turnright" then
  19. turnRight(splitString[2])
  20. else
  21. print("Please use forward <times>, turnLeft <times> or turnRight <times>")
  22. end
  23. end
Add Comment
Please, Sign In to add comment