Advertisement
RobotBubble

TypeTest

Oct 29th, 2017
162
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --
  2. -- QuickType - A small mini-game.
  3. -- Made by UseTheForce Productions
  4. --
  5. -- Credits:
  6. -- Luke M.
  7. --
  8.  
  9. if not fs.exists("CCQT/UTFPro") then
  10. fs.makeDir("CCQT")
  11. local UTFPro = fs.open("CCQT/UTFPro", "w")
  12. UTFPro.writeLine("bbbbbbbbbbbbb9")
  13. UTFPro.writeLine("b7bb88888777b9")
  14. UTFPro.writeLine("b7bb7b8b7bbbb9")
  15. UTFPro.writeLine("b7bb7b8b77bbb9")
  16. UTFPro.writeLine("b7bb7b8b7bbbb9")
  17. UTFPro.writeLine("b7777b8b7bbbb9")
  18. UTFPro.writeLine("bbbbbbbbbbbbb9")
  19. UTFPro.writeLine("99999999999999")
  20. UTFPro.close()
  21. end
  22.  
  23. img = paintutils.loadImage("CCQT/UTFPro")
  24. local score = 0
  25. local dgtime = 5
  26.  
  27. function clear()
  28. term.clear()
  29. term.setCursorPos(1,1)
  30. end
  31.  
  32. clear()
  33.  
  34. function saveScore(value)
  35. file = fs.open("CCQT/highscore.txt", "w")
  36. file.writeLine(value)
  37. file.close()
  38. end
  39.  
  40. function getScore()
  41. if not fs.exists("CCQT/highscore.txt") then
  42. file = fs.open("CCQT/highscore.txt", "w")
  43. file.writeLine("0")
  44. file.close()
  45. getScore()
  46. else
  47. file = fs.open("CCQT/highscore.txt", "r")
  48. highscore = file.readAll()
  49. file.close()
  50. return tonumber(highscore)
  51. end
  52. end
  53.  
  54. function gsleep()
  55. sleep(tonumber(gtime))
  56. return "HI"
  57. end
  58.  
  59. function easyQuestion()
  60. local letters = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
  61. local question = {letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)]}
  62. return question[1]..question[2]..question[3]..question[4]..question[5]..question[6]
  63. end
  64.  
  65. function hardQuestion()
  66. local letters = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
  67. local question = {letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)]}
  68. return question[1]..question[2]..question[3]..question[4]..question[5]..question[6]
  69. end
  70.  
  71. function insaneQuestion()
  72. local letters = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ":", "{", "}", "[", "]", "!", "@", "#", "$", "%", "%", "^", "&", "*", "(", ")", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "/", "\\"}
  73. local question = {letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)], letters[math.random(1, #letters)]}
  74. return question[1]..question[2]..question[3]..question[4]..question[5]..question[6]
  75. end
  76.  
  77. function easy()
  78. clear()
  79. eword = easyQuestion()
  80. print("Score: "..score)
  81. print("")
  82. print(eword)
  83. io.write("> ")
  84. einput = io.read()
  85. if string.lower(einput) == string.lower(eword) then
  86. print("Correct!")
  87. isCorrect = true
  88. elseif string.lower(einput) ~= string.lower(eword) then
  89. print("Incorrect! You have lost.")
  90. isCorrect = false
  91. hs = getScore()
  92. if tonumber(score) > tonumber(hs) then
  93. print("New High Score!!!")
  94. saveScore(score)
  95. end
  96. sleep(1)
  97. return false
  98. end
  99. end
  100.  
  101. function hard()
  102. clear()
  103. hword = hardQuestion()
  104. print("Score: "..score)
  105. print("")
  106. print(hword)
  107. io.write("> ")
  108. hinput = io.read()
  109. if hinput == hword then
  110. print("Correct!")
  111. isCorrect = true
  112. elseif einput ~= eword then
  113. print("Incorrect! You have lost.")
  114. isCorrect = false
  115. hs = getScore()
  116. if tonumber(score) > tonumber(hs) then
  117. print("New High Score!!!")
  118. saveScore(score)
  119. end
  120. sleep(1)
  121. return false
  122. end
  123. end
  124.  
  125. function insane()
  126. clear()
  127. iword = insaneQuestion()
  128. print("Score: "..score)
  129. print("")
  130. print(iword)
  131. io.write("> ")
  132. iinput = io.read()
  133. if iinput == iword then
  134. print("Correct!")
  135. isCorrect = true
  136. elseif einput ~= eword then
  137. print("Incorrect! You have lost.")
  138. isCorrect = false
  139. hs = getScore()
  140. if tonumber(score) > tonumber(hs) then
  141. print("New High Score!!!")
  142. saveScore(score)
  143. end
  144. sleep(1)
  145. return false
  146. end
  147. end
  148.  
  149. function moreInfo()
  150. clear()
  151. print(" <[[[QuickType]]]>")
  152. print("Info")
  153. print("")
  154. print("Copy what comes up on the screen as fast as you can. The time you typed in the beginning was how long you have to type the word in.\n")
  155. print("Easy: Not case-sensitive. Only Letters. Just copy!")
  156. print("")
  157. print("Hard: Case-sensitive. Only letters.")
  158. print("")
  159. print("Insane: Case-sensitive. Letters, numbers, symbols.")
  160. print("")
  161. print("Press any key to continue...")
  162. while true do
  163. event = os.pullEvent()
  164. if event == "key" then
  165. parallel.waitForAll(unosleep, hi)
  166. start()
  167. end
  168. end
  169. end
  170.  
  171. function unosleep()
  172. sleep(0.5)
  173. end
  174.  
  175. function hi()
  176. print("")
  177. print(" ...")
  178. end
  179.  
  180. function start()
  181. score = 0
  182. gtime = htime
  183. hs = getScore()
  184. repeat
  185. clear()
  186. print(" <[[[QuickType]]]> High Score: "..hs)
  187. print(" Choose your Gamemode:")
  188. print("")
  189. print(" Easy (e)")
  190. print(" Hard (h)")
  191. print(" Insane (i)")
  192. print(" More Info (m)")
  193. print(" Exit (ex)")
  194. print("")
  195. io.write(" > ")
  196. gamemode = string.lower(io.read())
  197.  
  198. if gamemode == "e" then
  199. gtype = "easy"
  200.  
  201. elseif gamemode == "h" then
  202. gtype = "hard"
  203.  
  204. elseif gamemode == "i" then
  205. gtype = "insane"
  206.  
  207. elseif gamemode == "ex" then
  208. print("Goodbye!")
  209. sleep(2)
  210. os.reboot()
  211. clear()
  212. error()
  213.  
  214. elseif gamemode == "m" then
  215. moreInfo()
  216.  
  217. else
  218. print("Invalid Answer")
  219. sleep(1)
  220. end
  221. until gtype ~= nil
  222. clear()
  223. print("Are you ready? (y/n)")
  224. io.write("> ")
  225. local input = string.lower(io.read())
  226. if input == "y" then
  227. clear()
  228. if gtype == "easy" then
  229. geasy()
  230. start()
  231. elseif gtype == "hard" then
  232. ghard()
  233. start()
  234. elseif gtype == "insane" then
  235. ginsane()
  236. start()
  237. else
  238. print("An Unknown Error Occurred...")
  239. sleep(2)
  240. error()
  241. end
  242. else
  243. start()
  244. end
  245. end
  246.  
  247. function geasy()
  248. x = parallel.waitForAny(gsleep, easy)
  249. if x == 2 then
  250. if isCorrect == false then
  251. start()
  252. else
  253. score = score + 1
  254. gtime = gtime - 0.2
  255. sleep(1)
  256. geasy()
  257. end
  258. end
  259. if x == 1 then
  260. print("\nTime is up! You lose!")
  261. if score > hs then
  262. print("New High Score!")
  263. saveScore(score)
  264. end
  265. sleep(2)
  266. return "HI"
  267. end
  268. end
  269.  
  270. function ghard()
  271. x = parallel.waitForAny(hard, gsleep)
  272. if x == 1 then
  273. if isCorrect == false then
  274. start()
  275. else
  276. score = score + 1
  277. gtime = gtime - 0.2
  278. sleep(1)
  279. geasy()
  280. end
  281. end
  282. if x == 2 then
  283. print("\nTime is up! You lose!")
  284. if score > hs then
  285. print("New High Score!")
  286. saveScore(score)
  287. end
  288. sleep(2)
  289. return "HI"
  290. end
  291. end
  292.  
  293. function ginsane()
  294. x = parallel.waitForAny(insane, gsleep)
  295. if x == 1 then
  296. if isCorrect == false then
  297. start()
  298. else
  299. score = score + 1
  300. gtime = gtime - 0.2
  301. sleep(1)
  302. geasy()
  303. end end
  304. if x == 2 then
  305. print("\nTime is up! You lose!")
  306. if score > hs then
  307. print("New High Score!")
  308. saveScore(score)
  309. end
  310. sleep(2)
  311. return "HI"
  312. end
  313. end
  314.  
  315. print("Getting highscore...")
  316. hs = getScore()
  317. function timew()
  318. io.write("Enter time > ")
  319. htime = tonumber(io.read())
  320. if htime == nil then
  321. print("Must be a number")
  322. timew()
  323. elseif htime < 0 then
  324. print("Must be greater than 0")
  325. timew()
  326. elseif htime > 10 then
  327. print("Must be less than or equal to 10")
  328. timew()
  329. else
  330. gtime = htime
  331. end
  332. end
  333. timew()
  334. print("Initializing...")
  335. sleep(0.82946)
  336. clear()
  337. sleep(1)
  338. if term.isColor() then
  339. paintutils.drawImage(img, 9, 4)
  340. term.setCursorPos(11, 13)
  341. term.setBackgroundColor(colors.black)
  342. write("UseTheForce Productions Presents")
  343. else
  344. term.setCursorPos(11, 10)
  345. write("UseTheForce Productions Presents")
  346. end
  347. sleep(3)
  348. term.setBackgroundColor(colors.black)
  349. clear()
  350. start()
Advertisement
RAW Paste Data Copied
Advertisement