Every-time-argument

From FreeSpace Wiki
Revision as of 03:42, 10 August 2007 by Goober5000 (talk | contribs) (we follow English grammar here)
Jump to: navigation, search
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.