Reputation: 27
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.
Upvotes: 0
Views: 372
Reputation: 23727
if key == "space" then
if paused then
love.audio.resume()
else
love.audio.pause()
end
paused = not paused
end
But love.audio.resume
was removed in LÖVE 11.
Use love.audio.play
instead.
Upvotes: 3