baton
baton copied to clipboard
Matching against patterns for inputs
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).
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.
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 ".*"