baton icon indicating copy to clipboard operation
baton copied to clipboard

Matching against patterns for inputs

Open weakman54 opened this issue 7 years ago • 2 comments

I would like to be able to match against patterns, atm, I have four combo inputs, and would like to check if any of them is pressed (to trigger the combo). right now this requires me to check each in turn, in one large or condition. being able to do something like

if input:pressed("combo%a*") then

would greatly help this.

I also have a use case where I just want to check against any button being pressed/released (I have some events that only trigger after a short amount of time of an input being held, which is tracked by a simple timer variable. I want to only increase this variable while any button is held, and reset each time a button is released).

weakman54 avatar Jun 18 '18 07:06 weakman54

This seems like it would be pretty straightforward to implement without cluttering the API. However, by any chance, would variable arguments (ie input:pressed('controlA', 'controlB', 'controlC')) also work? It's not as powerful as pattern matching, but pattern matching strikes me as a bit wonky for this application.

tesselode avatar Jun 18 '18 07:06 tesselode

sure, that would at least reduce repetition a bit. Though then the case to check against any key would be another special case, instead of just matching against ".*"

weakman54 avatar Jun 18 '18 12:06 weakman54