Welcome to the Creatures Wiki! Log in and join the community.

Difference between revisions of "ELIF"

From Creatures Wiki
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
'''ELIF''' is a [[CAOS]] command controlling [[flow (CAOS)|flow]], introduced in Creatures 3.
+
'''ELIF''' is a [[CAOS]] command controlling [[flow (CAOS)|flow]], introduced in Creatures 3. Before ELIF was invented, cobblers had to put a doif... else... doif... endi... endi structure in their code.
  
 
==Usage==
 
==Usage==
Line 7: Line 7:
  
 
ELIF should follow a DOIF and code block.
 
ELIF should follow a DOIF and code block.
 +
 +
It is generally more efficient to use ELIF rather than several DOIF-ENDI pairs after each other, as the engine usually runs 5 commands per [[TICK]] (unless [[INST]] is used).
  
 
{{caoswarning|ELIF may be used without a preceding DOIF, in which case it acts like DOIF. This feature is deprecated and should be avoided.}}
 
{{caoswarning|ELIF may be used without a preceding DOIF, in which case it acts like DOIF. This feature is deprecated and should be avoided.}}

Latest revision as of 06:25, 17 December 2023

ELIF is a CAOS command controlling flow, introduced in Creatures 3. Before ELIF was invented, cobblers had to put a doif... else... doif... endi... endi structure in their code.

Usage[edit]

Syntax: ELIF cond (condition)

"Else-if". Used between DOIF and ENDI. If the condition of no preceding DOIF or ELIF command has been true, but cond is true, then the following code block will be executed.

ELIF should follow a DOIF and code block.

It is generally more efficient to use ELIF rather than several DOIF-ENDI pairs after each other, as the engine usually runs 5 commands per TICK (unless INST is used).

Warning!
ELIF may be used without a preceding DOIF, in which case it acts like DOIF. This feature is deprecated and should be avoided.

See DOIF for more on conditional execution.