coded in Lua
my code is not functioning the way it suppose to and it was working fine a day ago but all the sudden it just changes with no explanation
UPDATE code has been cleaned but now just trying to loop it
https://replit.com/@DanielHernan163/In-Class-Psuedocode-to-Lua#GuessingGame.lua
--Computer picks a number from 1 to 10.
--User tries to guess the computer number.
--User is allowed a certain number of attempts (7)
--If user guesses correctly, user wins.
--If user does not guess correctly within the allowed number of attempts, user loses.
--Print a winning or losing message after each game.
--Allow the user to replay as many times as they want.]]
math.randomseed(os.time())
math.random() ; math.random() ; math.random()
checknum = math.random(1,10)
print (checknum)
done = false
counter = 0
num1 = nil
userChoice = nil
while done == false do
while counter < 7 do
while num1 == nil or not tonumber(num1) or num1 == "" do
print("please give me a guess: ")
num1 = io.read()
if counter == 7 then
print ("ran out of tries")
break
end
-- else if num1 ~= checknum then
-- print (" ")
-- print("Try Again: ")
-- counter = counter + 1
-- num1 = nil
--else if num1 == checknum then
-- print ("congrats its: ".. checknum)
-- end
if tonumber(num1) == tonumber(checknum) then
print ("congrats its: ".. checknum)
print ("Y to stop, other key to continue")
userChoice = io.read()
if string.upper (userChoice) == "Y" then
done = true
break
end
userChoice = nil
-- if num1 == nil or not tonumber(num1) or num1 == "" then
-- counter = 0
-- checknum = math.random(1,10)
-- print("please give me a guess: ")
-- num1 = io.read()
else print("Try Again: ")
counter = counter + 1
num1 = nil
end
end
end
end