love2d-community / love-api

The whole LÖVE wiki in a Lua table.
http://love2d-community.github.io/love-api/
299 stars 47 forks source link

Add love.handlers #57

Closed xordspar0 closed 2 years ago

xordspar0 commented 6 years ago

There is a table inside love called love.handlers that doesn't fit into the normal categories. It's not a module, function, or callback. It's just a table where you can define functions to handle user-defined events. It is documented here:

MikuAuahDark commented 2 years ago

IIRC the usage of love.handles for custom events is not supported. This means it can change between LOVE versions without prior notice or just stop working altogether.

Same goes to love.arg and love.path.

pablomayobre commented 2 years ago

These could be added in some way as secret or hidden variables, so that autocomplete providers could "support" them.

Since the love-api is generally deployed in a per-version basis and there are branches for all major releases, if the behaviour were to change, we can change the love-api to match or remove it altogether.

When using this undocumented feature (for example, to write a custom love.run, or when writing a library like hump.gamestate) and relying on a tool that uses love-api to check for the existance of the handlers, you may end up facing issues like:

So we could potentially add these to help those tools easily support this field, yet mark them as hidden or readonly or something similar so that people know that they shouldn't be used in normal operation.

I think a similar example to this is love.run, it's prone to change between versions, issues with custom love.run are the user's problem and yet it's documented for people to play with it, love.handlers is no rocket science, I think it deserves some docs at least here...