Posted 03 July 2016 - 08:53 PM
Hey!
I made a custom game from scratch, completely mine. I am pretty proud of it, but I want to add more. I want to make it more fun, so how would I implement high-score code so each time the player guesses with the least amount of guesses overrides the current high-score?
Here is my code:
Thanks!
I made a custom game from scratch, completely mine. I am pretty proud of it, but I want to add more. I want to make it more fun, so how would I implement high-score code so each time the player guesses with the least amount of guesses overrides the current high-score?
Here is my code:
tries = 1
term.clear()
term.setCursorPos(5,10)
print("Guess The NUMBER!")
sleep(0.25)
term.clear()
sleep(0.25)
term.setCursorPos(5,10)
print("Guess The NUMBER!")
sleep(0.5)
term.clear()
sleep(0.25)
term.setCursorPos(5,10)
print("Guess The NUMBER!")
sleep(2)
term.clear()
numb = math.random(1, 100)
term.setCursorPos(1,1)
print("A number has been chosen by the computer. Guess the number between 1 to 100. You will be given clues.")
term.setCursorPos(1,5)
while true do
write"Guess: "
guess = io.read()
guess = tonumber(guess)
if guess == numb then
term.clear()
term.setCursorPos(1,1)
print("You won with "..tries.." tries! The number was "..numb)
sleep(7)
os.shutdown()
else
if guess > numb then
print("Your guess was too high!")
elseif guess < numb then
print("Your guess was too low!")
else
print("Guess numbers, not letters!")
end
tries = tries + 1
end
end
Thanks!