Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while true do
- local splitString = {}
- print("Please enter a command: forward <times>, turnLeft <times> or turnRight <times>")
- local userInput = io.read()
- for i in string.gmatch(userInput, "%S+") do
- table.insert(splitString, i)
- end
- if #splitString ~= 2 then
- print("Please use forward <times>, turnLeft <times> or turnRight <times>")
- end
- if splitString[1] == "forward" then
- moveForward(splitString[2])
- elseif splitString[1] == "turnleft" then
- turnLeft(splitString[2])
- elseif splitString[1] == "turnright" then
- turnRight(splitString[2])
- else
- print("Please use forward <times>, turnLeft <times> or turnRight <times>")
- end
- end
Add Comment
Please, Sign In to add comment