Difference between revisions of "Every-time-argument"

From FreeSpace Wiki
Jump to: navigation, search
(New page: every-time-argument Every-time-argument (Conditional operator) This is a version of "when-argument" that will always evaluate its arguments. It's useful in situations where you ...)
 
m
 
(5 intermediate revisions by 2 users not shown)
Line 10: Line 10:
 
     Rest: Actions to take when the boolean expression becomes true.
 
     Rest: Actions to take when the boolean expression becomes true.
 
===Comments===
 
===Comments===
When using this, be careful that the conditions for it to trigger will not cause it to accidentally trigger indefinitely. Also, unlike a standard repeating event, there is no simple way to set a delay between triggerings when using <tt>every-time</tt>, though this can be hacked using a combination of variables and the [[Mission-time|mission-time]] SEXP to measure the desired delay - See the [[Stealthing Ships To Force Target Loss]] page in [[:Category:FRED_Examples|FRED_Examples]] for how this can be done.
+
<tt>[[Every-time]]</tt> and <tt>every-time-argument</tt> should be used extremely rarely, if ever, and only with careful and cautious planning.  Since these sexps will be evaluated in every single frame, they add a measurably larger performance overhead than a regular <tt>[[when]]</tt> or <tt>[[when-argument]]</tt> sexp.  Worse, since framerate can vary greatly between computers and even between playthroughs, improper use of these sexps can lead to wildly unpredictable (and even incorrect) results, as was famously demonstrated in the first few versions of [[The Procyon Insurgency]].  As described in the help texts, these sexps should ''only'' be used for volatile conditions that may become true more than once.
 +
 
 +
When using this sexp, be careful that the conditions for it to trigger will not cause it to accidentally trigger indefinitely. Also, unlike a standard repeating event, there is no simple way to set a delay between firings when using <tt>every-time</tt>.  It can be done, but only using advanced (and often complicated) methods.
  
 
[[Category:SCP SEXPs]]
 
[[Category:SCP SEXPs]]

Latest revision as of 03:46, 10 August 2007

every-time-argument
    Every-time-argument (Conditional operator)
    This is a version of "when-argument" that will always evaluate its arguments. It's useful in situations where you need to
    repeatedly  check things that may become true more than once. Since this sexp will execute every time it's evaluated,
    you may need to use it as an  argument to "when" (not "when-argument") if you want to impose restrictions on how it's called.

    Takes 3 or more arguments...
    1: The arguments to evaluate (see any-of, all-of, random-of, etc.).
    2: Boolean expression that must be true for actions to take place.
    Rest: Actions to take when the boolean expression becomes true.

Comments

Every-time and every-time-argument should be used extremely rarely, if ever, and only with careful and cautious planning. Since these sexps will be evaluated in every single frame, they add a measurably larger performance overhead than a regular when or when-argument sexp. Worse, since framerate can vary greatly between computers and even between playthroughs, improper use of these sexps can lead to wildly unpredictable (and even incorrect) results, as was famously demonstrated in the first few versions of The Procyon Insurgency. As described in the help texts, these sexps should only be used for volatile conditions that may become true more than once.

When using this sexp, be careful that the conditions for it to trigger will not cause it to accidentally trigger indefinitely. Also, unlike a standard repeating event, there is no simple way to set a delay between firings when using every-time. It can be done, but only using advanced (and often complicated) methods.