If Statement not functioning as hoped
Posted: Sat Dec 13, 2014 9:45 pm
I'm trying to create an if statement that will display text depending on the value of "playerState". As seen below:
However, upon running this it displays both pieces of text at once, no matter the value of playerState. I'm sure this is such a simple error, but I'm very new to Lua and LOVE.
If somebody could point me in the direction of where I am going wrong and how to correct it, I will be very thankful.
Code: Select all
function love.load()
playerState = ghost
normalText = "Player State is Normal"
ghostText = "Player State is Ghost"
end
function love.draw()
if playerState == normal then
love.graphics.print(normalText, 10, 10)
end
if playerState == ghost then
love.graphics.print(ghostText, 10, 10)
end
end
If somebody could point me in the direction of where I am going wrong and how to correct it, I will be very thankful.