vendredi 6 avril 2018

Problems with nested "IF" condition in Lua (Love2D)

Whenever I hit space bar I get this error: "Attempt to call field "resume" a nil value."
The intention is to the hit space bar once to stop the audio, and hit it again to resume.

if(key == "space") then
    love.audio.pause()
    paused = true
end
if paused == true then
    if (key == "space") then
        love.audio.resume()
    end 
end

Things I tried:
Changing "==" to "=" and vice versa;
Using "and" to avoid the nested "if" statement.

Documentation (if needed): http://love2d-community.github.io/love-api/#audio_resume

Any help is appreciated, and thank you for your time.

Aucun commentaire:

Enregistrer un commentaire