function Card:draw() end
function Card:update(dt)
if bla-bla then
bla-bla
end
function love.keypressed(k,u)
if (bla) then bla end
end
end
I defined the function love.keypressed inside another function in another file. How does that work?
Why does this function overwrites the same function at "main.lua"
by redefining love.keypressed() in cards.lua you overwrite the old one because otherwise when it is called LOVE wouldn't know which function to run. If you want to do an action in cards.lua when a key is pressed something like this would be best:
Pretty sure you shouldn't be defining functions like that. A fun and effective way to use the callbacks is with states and objects (or tables). Your states can be objects or just tables themselves.
I prefer to use the former because I like to think of it as assigning a value like you would with any other data type.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.