Reputation: 91
I am having a problem with my control statement. I have just started programming.
math.randomseed(os.time())
answers = {
123,
132,
231,
213,
321,
312
}
outcomes = ( answers[ math.random( #answers ) ] )
print("What is your first guess?")
io.write("Guess#1: \n")
g1 = io.read()
onetwothree()
function onetwothree()
if o = 123 and g1 = 321 then
print("You have no numbers correct")
end
end
os.execute("PAUSE")
When I run the code in my IDE, it displays this:
>lua -e "io.stdout:setvbuf 'no'" "Mastermind.lua"
lua: Mastermind.lua:25: 'then' expected near '='
>Exit code: 1
By the way, line 25, in my code is this:
if o = 123 and g1 = 321 then
How do I fix this and what is happening.
Upvotes: 3
Views: 61
Reputation: 4702
The problem is you're using =
for comparison instead of ==
.
Change your condition to:
if o == 123 and g1 == 321 then
Upvotes: 4