Posted 18 October 2012 - 09:58 PM
Hey there, I was making a Lua Higher or Lower game, but getting into the code it's confusing me, sometimes it doesn't work, and sometimes it does, and sometimes it just doesn't work at all.
Thank you! :P/>/>
term.clear()
term.setCursorPos(1,1)
print("My print stuff goes here, no worries about this")
print("more print stuff")
num = math.random(1,10)
print("your number is: ", num ," will the next number be higher or lower?")
mistakes = 0
correct = 0
whie true do
guess = read()
nextNum = math.random(1,10)
if guess == "h" and num < nextNum then
num = math.random(1,10)
print("correct! the new number is: ", num ," will the next be higher or lower?")
correct = correct + 1
else if guess == "l" and num > nextNum then
num = math.random(1,10)
print("wrong! the new number is: ", num ," will the next be higher or lower?")
mistakes = mistakes + 1
else
print("Please use h for higher and l for lower!")
end
if mistakes == 3 then
print("You've done 3 mistakes, GAME OVER")
print("Score: ", correct , "")
break
end
end
end
Thank you! :P/>/>