So I just started learning Lua and Love2D and am using global variables when I need callback functions to communicate with eachother. For example:
enter_pressed = false
function love.update(dt)
if love.keyboard.isDown('return') then
enter_pressed = true
end
end
function love.draw()
if enter_pressed then
love.graphics.print("Enter has been pressed", 100, 200)
end
Is there any way to avoid having to write such code?
I haven't tried anything yet except for googling for possible solutions.