Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. local function GetName()
  2.    write("Enter a name: ")
  3.    return read()
  4. end
  5.  
  6. local Name1 = GetName()
  7. local Name2 = GetName()
  8. local Name3 = GetName()
  9. local Name4 = GetName()
  10. local Name5 = GetName()
  11.  
  12. write("You have entered "..Name1.." "..Name2.." "..Name3.." "..Name4.." "..Name5)
  13.  
  14. -- The For Loop
  15. for i=1,10 do
  16.     print("i is "..tostring(i))
  17. end
  18.  
  19. -- Interactive For Loop
  20. write("How many times should I loop?")
  21. local Num = tonumber(read())
  22. for i=1,Num do
  23.     print("Looped "..tostring(i).." times.")
  24. end
  25.  
  26. -- Simplified First Script
  27. local string = ""
  28. for i=1,5 do
  29.   write("Enter a name: ")
  30.   string=string.." "..read()
  31. end
  32. write("You have entered "..string)
  33.  
  34. -- The While loop
  35. local Answer, Correct = "", "2"
  36. while Answer ~= Correct do
  37.    write("What is the sum of 1 and 1 (1+1)? ")
  38.    Answer = read()
  39.    
  40.    if Answer == Correct then print("Correct!") else print("Incorrect!") end
  41. end
  42.  
  43. -- The Repeat Loop
  44. local i = 1
  45. repeat
  46.   print(i)
  47.   i = i + 1
  48. until i == 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement