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

TYPE

From Creatures Wiki
Jump to navigation Jump to search

TYPE is a CAOS command used to find the type of a token.

Usage[edit]

Syntax: TYPE something

Returns an integer from the following list depending on what something is.

Examples[edit]

This is an obvious 'print anything' command. It prints va00.

DOIF TYPE va00 eq 0 or TYPE va00 eq 1
  OUTV va00
ELIF TYPE va00 eq 2
  OUTS va00
ELIF TYPE va00 ge 3 and TYPE va00 le 7
  DOIF TYPE va00 eq 3
    OUTS "Simple"
  ELIF TYPE va00 eq 4
    OUTS "Pointer"
  ELIF TYPE va00 eq 5
    OUTS "Compound"
  ELIF TYPE va00 eq 6
    OUTS "Vehicle"
  ELIF TYPE va00 eq 7
    OUTS "Creature"
  ENDI
  TARG va00
  OUTS " agent, class number "
  OUTV FMLY OUTS " " OUTV GNUS OUTS " " OUTV SPCS
  OUTS ", current id "
  OUTV UNID
ELIF TYPE va00 eq -1
  OUTS "NULL agent"
ELSE
  OUTS "ERROR"
ENDI

Bugs[edit]

Attempting to check the TYPE of a NAME variable named an empty string ("") will return '0' but will render the agent unable to access NAME variables via NAMN. (Variables can still be accessed directly)

*this line breaks the targ agent so NAMN no longer is able to find NAME variables on the agent
outv type name ""

Because of this, be cautious when using TYPE in conjunction with NAMN to check the types of NAME variables, since NAMN will return an empty string at when there are no more variables, triggering the bug if it is then TYPE checked.

*do not do this, because if va00 is an empty string, it will break the agent
namn va00
outv type name va00
*do this instead
namn va00
doif va00 ne ""
outv type name va00
endi

GAME and EAME variables are not susceptible to this bug, as the engine will throw an error if a script tries to access an empty-string variable.


External links[edit]