Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 words5 = {"About","Above","After","Again","Apple","Began","Begin","Black","Block","Bring","Brook","Brown","Build","Carry","Chair","Color","Cloud","Dance","Drink","Empty","Found","Funny","Green","Guess","Happy","Hello","Horse","House","Hurry","Large","Laugh","Learn","Maybe","Never","Paint","Penny","Store","Thank","Their","Train","Truck","Under","Where","Which","White","Would"}
- local words6 = {"Across","Afraid","Always","Animal","Answer","Anyone","Around","Basket","Before","Behind","Belong","Beside","Better","Bitter","Bottle","Bottom","Bought","Bounce","Branch","Bridge","Button","Candle","Cannot","Caught","Cellar","Chance","Cowboy","Doctor","Dragon","Father","Friend","Kitten","Little","Mother","Peanut","Please","Pocket","Rabbit","Rocket","School","Should","Sister","Street","Turtle","Window","Yellow"}
- local words7 = {"Address","Against","Already","Another","Anxious","Balcony","Balloon","Battery","Because","Bedroom","Believe","Beneath","Between","Blossom","Bicycle","Blanket","Brother","Careful","Chicken","Country","Cupcake","Evening","Excited","Feather","Herself","Himself","Instead","Kitchen","Morning","Nothing","Outside","Picture","Raccoon","Snowman","Someone","Stopped","Thought","Through","Tonight","Tractor","Traffic","Trouble","Unhappy","Whisper","Whistle","Without"}
- local words8 = {"Accident","Airplane","Although","Anything","Anywhere","Backward","Backyard","Barnyard","BaseBall","Bithday","Business","Cheerful","Complain","Complete","Continue","Customer","Darkness","Daughter","Daydream","Discover","Distance","Doorbell","Electric","Election","Elephant","Elevator","Enormous","Everyone","Favorite","Football","Fountain","Friendly","Frighten","Goodness","Grateful","Handsome","Lemonade","Mountain","Neighbor","Remember","Sidewalk","Sometime","Squirrel","Suprise","Together","Tommorow","Yourself"}
- local health,currentletter = 7,1
- local level = 1
- function printc(str, xpos, ypos)
- term.setCursorPos(xpos,ypos)
- write(str)
- end
- function winner()
- local w,h = term.getSize()
- level = level + 1
- mc= false
- printc("Congratulations Level up!",w/2-(string.len("Congratulations Level up!")/2)+1,17)
- sleep(3)
- play()
- end
- local function findAll(s, pattern, plain)
- local i = 1
- local result = {}
- while i < #s do
- local pos = string.find(s, pattern, i, plain)
- if not pos then
- break
- end
- table.insert(result, pos)
- i = pos + 1
- end
- return result
- end
- function loser()
- mc= false
- printc("| |",2,16)
- local w,h = term.getSize()
- local printit = "Your Word was: "..word
- printc("You Lose!",w/2-(string.len("You Lose!")/2)+1,15)
- printc(printit,w/2-(#printit/2)+1,16)
- sleep(2)
- menu()
- end
- function drawframe()
- term.clear()
- printc("+----------------------------------------------+",2,1)
- printc("| Used Letters: |",2,2)
- printc("+----------------------------------+-----------+",2,3)
- printc("| ______________ | Level: |",2,4)
- printc("| |/ | +-----------+",2,5)
- printc("| | |",2,6)
- printc("| | |",2,7)
- printc("| | |",2,8)
- printc("| | |",2,9)
- printc("| | |",2,10)
- printc("| | |",2,11)
- printc("| | |",2,12)
- printc("| | |",2,13)
- printc("| __|__ |",2,14)
- printc("| |",2,15)
- printc("| - - |",2,16)
- printc("| |",2,17)
- printc("+----------------------------------------------+",2,18)
- end
- function chooseword()
- if level <= 5 then words = words5 end
- if level >= 6 and level <= 10 then words = words6 end
- if level >= 11 and level <= 15 then words = words7 end
- if level >= 16 and level <= 20 then words = words8 end
- blank = {}
- word = words[math.random(1,#words)]
- for i=1,#word do table.insert(blank,"_")
- term.setCursorPos(22,16)
- for i=1,#blank do write(blank[i].." ") end
- end
- end
- function losehealth()
- health = health - 1
- if health == 6 then printc("/ \\",22,6);printc("\\ /",22,7) end --Head
- if health == 5 then printc("|",23,8);printc("|",23,9);printc("|",23,10) end --Body
- if health == 4 then printc("\\",21,8);printc("\\",22,9) end --Left Arm
- if health == 3 then printc("/",25,8);printc("/",24,9) end --Right Arm
- if health == 2 then printc("/",22,11);printc("_/",20,12) end --Left Leg
- if health == 1 then printc("\\",24,11);printc("\\_",25,12);loser() end --Right Leg
- end
- function play()
- health = 7
- usedletters = {}
- drawframe()
- chooseword()
- printc(letters[currentletter],10,16)
- mc=true
- printc(level,47,4)
- end
- function checkletter(number)
- local varr,varr2 = true,true
- for i=1,#usedletters do
- if tonumber(usedletters[i]) == currentletter then varr = false;break end
- end
- if varr then
- table.insert(usedletters, currentletter)
- term.setCursorPos(18,2)
- for i=1,#usedletters do write(letters[tonumber(usedletters[i])].." ") end
- for _,i in ipairs(findAll(string.lower(word), string.lower(letters[number]))) do
- if i ~= 1 then blank[i] = string.lower(letters[number]) else blank[i] = letters[number] end
- term.setCursorPos(22,16)
- for i=1,#blank do write(blank[i].." ") end
- end
- for i=1,#blank do -- checks for a win or not, if no under scores exist in #blank then you win
- if blank[i] == "_" then break end
- if i == #blank and #blank ~= "_" then winner() end
- end
- if string.find(string.lower(word),string.lower(letters[number])) == nil then losehealth() end
- end
- end
- function menu()
- term.clear()
- local w,h = term.getSize()
- printc("_ _ ____ _ _ ____ _ _ ____ _ _",w/2-(string.len("_ _ ____ _ _ ____ _ _ ____ _ _")/2)+1,4)
- printc("|__| |__| |\\ | | __ |\\/| |__| |\\ |",w/2-(string.len("|__| |__| |\\ | | __ |\\/| |__| |\\ |")/2)+1,5)
- printc("| | | | | \\| |__] | | | | | \\|",w/2-(string.len("| | | | | \\| |__] | | | | | \\|")/2)+1,6)
- printc(" Press Enter To Play ",w/2-(string.len(" Press Enter To Play ")/2)+1,12)
- local fvar = true
- os.startTimer(1)
- local mc2 = true
- while mc2 do
- local event, param = os.pullEventRaw()
- if event == "timer" then
- if fvar == true then
- printc("[Press Enter To Play]",w/2-(string.len("[Press Enter To Play]")/2)+1,12)
- os.startTimer(1)
- fvar = false
- else
- printc(" Press Enter To Play ",w/2-(string.len(" Press Enter To Play ")/2)+1,12)
- os.startTimer(1)
- fvar = true
- end
- elseif event == "key" and param == 28 then mc2 = false;level = 1;play() end
- end
- end
- menu()
- while mc == true do
- local event,param = os.pullEventRaw()
- if event == "key" then
- if param == 208 then -- down
- currentletter = currentletter +1
- if currentletter == 27 then currentletter = 1 end
- printc(letters[currentletter],10,16)
- elseif param == 200 then -- up
- currentletter = currentletter -1
- if currentletter == 0 then currentletter = 26 end
- printc(letters[currentletter],10,16)
- elseif param == 28 then -- enter
- checkletter(currentletter)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement