Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- QuickType - A small mini-game.
- -- Made by UseTheForce Productions
- --
- -- Credits:
- -- Luke M.
- --
- if not fs.exists("CCQT/UTFPro") then
- fs.makeDir("CCQT")
- local UTFPro = fs.open("CCQT/UTFPro", "w")
- UTFPro.writeLine("bbbbbbbbbbbbb9")
- UTFPro.writeLine("b7bb88888777b9")
- UTFPro.writeLine("b7bb7b8b7bbbb9")
- UTFPro.writeLine("b7bb7b8b77bbb9")
- UTFPro.writeLine("b7bb7b8b7bbbb9")
- UTFPro.writeLine("b7777b8b7bbbb9")
- UTFPro.writeLine("bbbbbbbbbbbbb9")
- UTFPro.writeLine("99999999999999")
- UTFPro.close()
- end
- img = paintutils.loadImage("CCQT/UTFPro")
- local score = 0
- local dgtime = 5
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- clear()
- function saveScore(value)
- file = fs.open("CCQT/highscore.txt", "w")
- file.writeLine(value)
- file.close()
- end
- function getScore()
- if not fs.exists("CCQT/highscore.txt") then
- file = fs.open("CCQT/highscore.txt", "w")
- file.writeLine("0")
- file.close()
- getScore()
- else
- file = fs.open("CCQT/highscore.txt", "r")
- highscore = file.readAll()
- file.close()
- return tonumber(highscore)
- end
- end
- function gsleep()
- sleep(tonumber(gtime))
- return "HI"
- end
- function easyQuestion()
- 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"}
- 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)]}
- return question[1]..question[2]..question[3]..question[4]..question[5]..question[6]
- end
- function hardQuestion()
- 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"}
- 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)]}
- return question[1]..question[2]..question[3]..question[4]..question[5]..question[6]
- end
- function insaneQuestion()
- 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", "/", "\\"}
- 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)]}
- return question[1]..question[2]..question[3]..question[4]..question[5]..question[6]
- end
- function easy()
- clear()
- eword = easyQuestion()
- print("Score: "..score)
- print("")
- print(eword)
- io.write("> ")
- einput = io.read()
- if string.lower(einput) == string.lower(eword) then
- print("Correct!")
- isCorrect = true
- elseif string.lower(einput) ~= string.lower(eword) then
- print("Incorrect! You have lost.")
- isCorrect = false
- hs = getScore()
- if tonumber(score) > tonumber(hs) then
- print("New High Score!!!")
- saveScore(score)
- end
- sleep(1)
- return false
- end
- end
- function hard()
- clear()
- hword = hardQuestion()
- print("Score: "..score)
- print("")
- print(hword)
- io.write("> ")
- hinput = io.read()
- if hinput == hword then
- print("Correct!")
- isCorrect = true
- elseif einput ~= eword then
- print("Incorrect! You have lost.")
- isCorrect = false
- hs = getScore()
- if tonumber(score) > tonumber(hs) then
- print("New High Score!!!")
- saveScore(score)
- end
- sleep(1)
- return false
- end
- end
- function insane()
- clear()
- iword = insaneQuestion()
- print("Score: "..score)
- print("")
- print(iword)
- io.write("> ")
- iinput = io.read()
- if iinput == iword then
- print("Correct!")
- isCorrect = true
- elseif einput ~= eword then
- print("Incorrect! You have lost.")
- isCorrect = false
- hs = getScore()
- if tonumber(score) > tonumber(hs) then
- print("New High Score!!!")
- saveScore(score)
- end
- sleep(1)
- return false
- end
- end
- function moreInfo()
- clear()
- print(" <[[[QuickType]]]>")
- print("Info")
- print("")
- 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")
- print("Easy: Not case-sensitive. Only Letters. Just copy!")
- print("")
- print("Hard: Case-sensitive. Only letters.")
- print("")
- print("Insane: Case-sensitive. Letters, numbers, symbols.")
- print("")
- print("Press any key to continue...")
- while true do
- event = os.pullEvent()
- if event == "key" then
- parallel.waitForAll(unosleep, hi)
- start()
- end
- end
- end
- function unosleep()
- sleep(0.5)
- end
- function hi()
- print("")
- print(" ...")
- end
- function start()
- score = 0
- gtime = htime
- hs = getScore()
- repeat
- clear()
- print(" <[[[QuickType]]]> High Score: "..hs)
- print(" Choose your Gamemode:")
- print("")
- print(" Easy (e)")
- print(" Hard (h)")
- print(" Insane (i)")
- print(" More Info (m)")
- print(" Exit (ex)")
- print("")
- io.write(" > ")
- gamemode = string.lower(io.read())
- if gamemode == "e" then
- gtype = "easy"
- elseif gamemode == "h" then
- gtype = "hard"
- elseif gamemode == "i" then
- gtype = "insane"
- elseif gamemode == "ex" then
- print("Goodbye!")
- sleep(2)
- os.reboot()
- clear()
- error()
- elseif gamemode == "m" then
- moreInfo()
- else
- print("Invalid Answer")
- sleep(1)
- end
- until gtype ~= nil
- clear()
- print("Are you ready? (y/n)")
- io.write("> ")
- local input = string.lower(io.read())
- if input == "y" then
- clear()
- if gtype == "easy" then
- geasy()
- start()
- elseif gtype == "hard" then
- ghard()
- start()
- elseif gtype == "insane" then
- ginsane()
- start()
- else
- print("An Unknown Error Occurred...")
- sleep(2)
- error()
- end
- else
- start()
- end
- end
- function geasy()
- x = parallel.waitForAny(gsleep, easy)
- if x == 2 then
- if isCorrect == false then
- start()
- else
- score = score + 1
- gtime = gtime - 0.2
- sleep(1)
- geasy()
- end
- end
- if x == 1 then
- print("\nTime is up! You lose!")
- if score > hs then
- print("New High Score!")
- saveScore(score)
- end
- sleep(2)
- return "HI"
- end
- end
- function ghard()
- x = parallel.waitForAny(hard, gsleep)
- if x == 1 then
- if isCorrect == false then
- start()
- else
- score = score + 1
- gtime = gtime - 0.2
- sleep(1)
- geasy()
- end
- end
- if x == 2 then
- print("\nTime is up! You lose!")
- if score > hs then
- print("New High Score!")
- saveScore(score)
- end
- sleep(2)
- return "HI"
- end
- end
- function ginsane()
- x = parallel.waitForAny(insane, gsleep)
- if x == 1 then
- if isCorrect == false then
- start()
- else
- score = score + 1
- gtime = gtime - 0.2
- sleep(1)
- geasy()
- end end
- if x == 2 then
- print("\nTime is up! You lose!")
- if score > hs then
- print("New High Score!")
- saveScore(score)
- end
- sleep(2)
- return "HI"
- end
- end
- print("Getting highscore...")
- hs = getScore()
- function timew()
- io.write("Enter time > ")
- htime = tonumber(io.read())
- if htime == nil then
- print("Must be a number")
- timew()
- elseif htime < 0 then
- print("Must be greater than 0")
- timew()
- elseif htime > 10 then
- print("Must be less than or equal to 10")
- timew()
- else
- gtime = htime
- end
- end
- timew()
- print("Initializing...")
- sleep(0.82946)
- clear()
- sleep(1)
- if term.isColor() then
- paintutils.drawImage(img, 9, 4)
- term.setCursorPos(11, 13)
- term.setBackgroundColor(colors.black)
- write("UseTheForce Productions Presents")
- else
- term.setCursorPos(11, 10)
- write("UseTheForce Productions Presents")
- end
- sleep(3)
- term.setBackgroundColor(colors.black)
- clear()
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement