So there are a bunch of events and things that I was thinking certain functions could use. Functions like while
, until
, if
and unless
.
The first two would make it make sense to think of these thingies as events, but the others would do better as booleans.
These are what I'm talking about:
LeftMouse, RightMouse,
ScrollUp, ScrollDown,
Key0 - Key9,
NumKey0 - NumKey9,
KeyA - KeyZ,
KeyEnter,
(etc.)
All of those are written in a way that makes you think of them as booleans, but you can also think of them as events - especially in this specific scenario:
// do something...
pause until KeyN;
// program continues after N is pressed
And, although I'm not sure about the specific pause
keyword, I like this syntax - it's very similar to await
in JavaScript. It also means you can pause while
N is pressed too.
Buuut, it's like a boolean so while foo
is the same as until !foo
, and if I support not
(!
), I may as well support and
(&
) and or
(|
) too.
pause until (KeyN & KeyE & KeyX & KeyT) | (KeyG & KeyO);
Now that's great and all, but some bugs can arise if a user has the same key event for multiple pause-points. If you held down that key, the transitions could zip past really quickly. This can be resolved by doing something like this:
pause until KeyN;
pause until !KeyN; // or use while instead of until not
But I'd like to do some syntactic sugar and introduce a then
(,
) boolean operation (it's not really an operation, I just don't know what else to call it). It's certainly an interesting one, and it doesn't really make much sense for an if
, but it sure does for a while
or until
!
...does exactly as above but on only one line! I like it very much.
I don't know how I'll implement it though...