Lieutenant_Damn Posted August 20, 2012 Posted August 20, 2012 I was trying to make a 'Guess the Number' program in computercraft, and I came up with this code: disp_hint = "hint" write("Enter a number!") number = read() write("Enter a hint for the number!") hint = read() term.clear() term.serCursorPos(1,1) repeat print("Guess the number, or type hint for a hint!") guess = read() if guess == number then print("You're Right!") end elseif guess == disp_hint then print("..hint..") else print("Nope!") end until guess == number exit() I get the error "bios:206: [string "guessthenumber.lua"]:15: 'until' expected (to close 'repeat' at line 9)" I know its a problem with the loop, but I cant figure out how to solve it. Will someone be my wife and point out the problems? Quote
Gator96100 Posted August 21, 2012 Posted August 21, 2012 Try: disp_hint = "hint" write("Enter a number!") number = tonumber(read()) write("Enter a hint for the number!") hint = read() term.clear() term.serCursorPos(1,1) repeat print("Guess the number, or type hint for a hint!") guess = tonumber(read()) if guess == number then print("You're Right!") elseif guess == disp_hint then print("..hint..") else print("Nope!") end until guess == number exit() I remove the "end" at line 14 and add "tonumber()"this is optional just makes it a real Integer:D. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.