Advertisement
yokmama

推測

Jun 9th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. -- 推測, coded in Lua, for ComputerCraft by Kaleb702 is licensed under a
  2. -- Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
  3.  
  4. -- 初期化 --
  5.  
  6. do
  7.     numb = math.random(1,100)
  8.     tries = 1
  9.     triesmax = 7
  10.     version = 1.2
  11.     win = false
  12. end
  13.  
  14. -- イントロ --
  15.  
  16. do
  17.     term.clear()
  18.     textutils.slowPrint("-------------------------------")
  19.     textutils.slowPrint("suisoku v" .. version)
  20.     textutils.slowPrint("-------------------------------")
  21.     print("Enter wo osite kudasai...")
  22.     io.read()
  23.     print("Anata ha watasi ga kakusite iru suuji wo ateru chance ga 6 kai arimasu")
  24. end
  25.  
  26. -- メイン処理 --
  27.  
  28. while true do
  29.     if tries > triesmax then
  30.         break
  31.     else
  32.         print("Watashi ga kakusite iru suuji ha 1-100 no uchi dore deshou? > ")
  33.         guess = io.read()
  34.         guess = tonumber(guess)
  35.         if guess == numb then
  36.             win = true
  37.             break
  38.         else
  39.             print("Hazure desu!")
  40.             if guess > numb then
  41.                 print("Sono suuji ha ookii desu")
  42.             elseif guess < numb then
  43.                 print("Sono suuji ha chiisai desu")
  44.             else
  45.                 print("Nani wo itteiruno desuka?")
  46.             end
  47.             tries = tries + 1
  48.         end
  49.     end
  50. end
  51.  
  52. -- Outro --
  53.  
  54. do
  55.     term.clear()
  56.     textutils.slowPrint("Game Over")
  57.     if win == true then
  58.         print("Shousha: Anata")
  59.     else
  60.         print("Shousha: Computer")
  61.     end
  62.         textutils.slowPrint("Thank you for choosing Kapow Creations.")
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement