aboutsummaryrefslogtreecommitdiffstats
path: root/lib/util.moon
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util.moon')
-rw-r--r--lib/util.moon14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/util.moon b/lib/util.moon
index 6da3698..af5d8f8 100644
--- a/lib/util.moon
+++ b/lib/util.moon
@@ -51,6 +51,19 @@ like (switch ...) except that the unused inputs are paused."
active\update dt
active\get!
+class edge extends Op
+ setup: (@i) =>
+ @value = false
+ @last = false
+
+ update: (dt) =>
+ @i\update dt
+
+ now = @i\get!
+
+ @value = not @last and now
+ @last = now
+
class keep extends Op
@doc: "(keep value [default]) - keep the last non-nil value
@@ -68,5 +81,6 @@ default defaults to zero."
{
'switch': switch_
'switch-': switch_pause
+ :edge
:keep
}