Hello everybody, I'm new to Lua programming.
I'm trying to work on a simple countdown, but Love gives me an error:
--
Error
Syntax Error: main.lua:16: 'then' expected near '='
--
here is my simple code:
function love.load()
love.graphics.setBackgroundColor(255, 255, 255)
totalTime = 30
gameOver = false
end
function love.update(dt)
totalTime = totalTime - dt
if totalTime <= 0 then
gameOver = true
end
end
function love.draw()
if gameOver = true then
love.graphics.print("GAME OVER", 100, 100)
end
end
I don't get why does Love tells that the syntax is wrong :/
[SOLVED]Simple Countdown doesnt work.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[SOLVED]Simple Countdown doesnt work.
Last edited by W3LF on Sat Feb 13, 2016 8:29 am, edited 1 time in total.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Simple Countdown doesnt work.
Please use code tags next time, as it makes the code more readable (and preserves identation).
As for the issue, in love.draw your code says "if gameOver = true then", that should be ==, rather than =.
As for the issue, in love.draw your code says "if gameOver = true then", that should be ==, rather than =.
Re: Simple Countdown doesnt work.
Uh, i'm so stupid.
Btw, I use tags, it's just Copy-Paste's effect, i'll be more careful next time
Btw, I use tags, it's just Copy-Paste's effect, i'll be more careful next time
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Simple Countdown doesnt work.
Code: Select all
These kind of tags: [code]
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Simple Countdown doesnt work.
Code: Select all
if gameOver = true then
Code: Select all
if gameOver == true then
Alternatively, you can simply write
Code: Select all
if gameOver then
Re: Simple Countdown doesnt work.
Oh, alright, sorry.zorg wrote:[/code]Code: Select all
These kind of tags: [code]
Who is online
Users browsing this forum: Bing [Bot] and 2 guests