User Tools

Site Tools


harlowe:event

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

harlowe:event [2019/04/16 03:06]
l created
harlowe:event [2019/04/16 03:07] (current)
l
Line 3: Line 3:
 Hooks that have this [[harlowe:​changer|changer]] attached will only be run when the given condition becomes true. Hooks that have this [[harlowe:​changer|changer]] attached will only be run when the given condition becomes true.
  
-####Example usage: +=== Example usage: ​===
-``` +
-(event: when time > 5s)[Oops, I forgot the next link: [[Go east]].] +
-```+
  
-####​Rationale:​ +''​%%(eventwhen time > 5s)[Oops, I forgot the next link: [[Go east]].]%%''​
-While the [[harlowe:​live|(live:)]] macro is versatile in providing time-based text updating, one of its common uses - checking if some +
-variable has changed using [[harlowe:​if|(if:​)]],​ and then displaying a hook and stopping the macro with [[harlowe:​stop|(stop:​)]] - is rather +
-cumbersome. This macro provides that functionality in a shorter form - the example above is equivalent to: +
-``` +
-{(live: 0.2s)[ +
-(if: time > 5s)[ +
-Oops, I forgot the next link: [[Go east]]. +
-+
-]+
-```+
  
-####Details: +=== Rationale: === 
-This macro only takes a "​when"​ [[harlowe:​lambda|lambda]],​ which is like a "​where"​ lambda but with "​where"​ changed to + 
-"​when"​ for readability purposes. This lambda doesn'​t have a temp variable before "​when"​ - it doesn'​t iterate over anything, +While the [[harlowe:​live|(live:​)]] macro is versatile in providing time-based text updating, one of its common uses - checking if some variable has changed using [[harlowe:​if|(if:​)]],​ and then displaying a hook and stopping the macro with [[harlowe:​stop|(stop:​)]] - is rather cumbersome. This macro provides that functionality in a shorter form - the example above is equivalent to: ''​%%{(live:​ 0.2s)[ (if: time > 5s)[ Oops, I forgot the next link: [[Go east]]. ] ]}%%''​ 
-except, perhaps, moments in time.+ 
 +=== Details: ​=== 
 + 
 +This macro only takes a "​when"​ [[harlowe:​lambda|lambda]],​ which is like a "​where"​ lambda but with "​where"​ changed to "​when"​ for readability purposes. This lambda doesn'​t have a temp variable before "​when"​ - it doesn'​t iterate over anything, except, perhaps, moments in time.
  
 Because (event:) hooks only run once, the [[harlowe:​stop|(stop:​)]] macro is unnecessary here. Because (event:) hooks only run once, the [[harlowe:​stop|(stop:​)]] macro is unnecessary here.
  
-Currently, you **cannot** attach (event:) to a [[harlowe:​command|command]] (such as in `(event: when $a is 1)(link-goto:"?"​)`). You have to wrap the command +Currently, you **cannot** attach (event:) to a [[harlowe:​command|command]] (such as in ''​%%(event: when $a is 1)(link-goto:"?"​)%%''​). You have to wrap the command in a hook (such as ''​%%(event:when $a is 1)[(link-goto:"?"​)]%%''​). 
-in a hook (such as `(event:when $a is 1)[(link-goto:"?"​)]`).+ 
 +=== See also: ===
  
-####See also: 
 [[harlowe:​live|(live:​)]] [[harlowe:​live|(live:​)]]
harlowe/event.txt · Last modified: 2019/04/16 03:07 by l