When I run the code it tells me there's an error which is ')' expected near '='
:
function restartLvl()
for i = 1, #balloonTexts do
display.remove(balloonTexts[i])
print ("restart level")
end
score.text = '0'
ballRemain.text = '3'
balloonText = {}
createBalloons(1, 3)
if (askUser.isVisible = true) then --this is the line where the error occured
askUser.isVisible = false
end
if (yesBtn.isVisible = true) then
yesBtn.isVisible = false
end
if (noBtn.isVisible = true) then
noBtn.isVisible = false
end
end
I don't know how it is still missing a ')
', because I closed all the brackets.
A simple trick to find unbalanced braces and parentheses in C and C++ files is to run GNU indent across them. Throw away the output and only look at the warnings and errors produced, they will show unbalanced braces and parentheses also in dead code.
Brackets, or braces, are a syntactic construct in many programming languages. They take the forms of "[]", "()", "{}" or "<>." They are typically used to denote programming language constructs such as blocks, function calls or array subscripts. Brackets are also known as braces.
=
is the assignment operator, ==
is the operator to test equality. Change it to:
if (askUser.isVisible == true) then
askUser.isVisible = false
end
And all the others as well. The brackets ()
can be ommited for simplicity:
if askUser.isVisible == true then
askUser.isVisible = false
end
If the value is a boolean, you can also do this because all values that are not nil
or false
are treated as true.
if askUser.isVisible then
askUser.isVisible = false
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With