Advertisement
masterp443

v0.4.3 Solve the Anagram

Dec 24th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.86 KB | None | 0 0
  1. term.clear()
  2. do
  3.    vers = "v0.4.3"
  4.    game = "Solve the Anagram!"  
  5.    seed = math.random(1,3)
  6.    anagram = nil
  7.    answer = nil
  8.    win = false
  9.    tries = 1
  10. end
  11. -- Introduction --
  12. textutils.slowPrint("-----------------0-----------------")
  13. print("Welcome to "..game.." "..vers)
  14. textutils.slowPrint("-----------------0-----------------")
  15. print("What's your name?")
  16. local name = read()
  17. print("The computer will present a jumbled set of letters.")
  18. print("Your job is to rearrange those letters and " ..game)
  19. -- Seed --
  20. while true do
  21.    if seed == 1 then
  22.       anagram = "mrranga"
  23.       answer = "anagram"
  24.       textutils.slowPrint("Your anagram to solve is "..anagram)
  25.       break
  26.    elseif seed == 2 then    
  27.       anagram = "ginamrei"
  28.       answer = "migraine"
  29.       textutils.slowPrint("Your anagram to solve is "..anagram)
  30.       break
  31.    elseif seed == 3 then
  32.       anagram = "rltntuensac"
  33.       answer = "translucent"
  34.       textutils.slowPrint("Your anagram to solve is "..anagram)
  35.       break
  36.    end
  37. end
  38. -- Main game loop --
  39. while true do
  40.    guess = io.read()
  41.    if guess == answer then
  42.       win = true
  43.       break
  44.    else
  45.       print("Incorrect! Try again.")
  46.       end
  47.    tries = tries + 1
  48. end
  49. -- Outro --
  50. do
  51.    if win == true then
  52.       term.clear()
  53.       print("CONGRATULATIONS!")
  54.       textutils.slowPrint("The answer was " ..answer..".")
  55.       textutils.slowPrint("Thank you for playing " ..game.." "..vers)
  56.       if tries == 1 then
  57.          print("You took 1 try to find the answer. Awesome!")
  58.       else
  59.          print("You took "..tries.." tries to find the answer.")
  60.       end
  61.       if name == " " then
  62.          textutils.slowPrint("See you later!")
  63.       else
  64.          textutils.slowPrint("See you later, "..name.."!")
  65.    end
  66. end
  67. -- Answers --
  68. -- anagram
  69. -- mraanga
  70.  
  71. -- migraine
  72. -- ginamrei
  73.  
  74. -- translucent
  75. -- rltntuensac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement