CAOS-Programmierung: Befehlsgruppen: Variables

Variables

ABSV (command) var (variable)

Makes a variable positive (its absolute value), so if var is negative var = 0 - var, otherwise var is left alone.

ACOS (float) x (float)

Returns arccosine of x in degrees.

ADDS (command) var (variable) append (string)

Concatenates two strings, so var = var + append.

ADDV (command) var (variable) sum (decimal)

Adds two integers or floats, so var = var + sum.

ANDV (command) var (variable) value (integer)

Peform a bitwise AND on an integer variable, so var = var & value.

ASIN (float) x (float)

Returns arcsine of x in degrees.

ATAN (float) x (float)

Returns arctangent of x in degrees.

AVAR (variable) agent (agent) index (integer)

This is the OVnn variable of the agent passed in. It is equivalent to target agent, OVnn, but means that you don't need to target it first :) You can 
also use them to implement primitive arrays.

CHAR (command) string (variable) index (integer) character (integer)

Sets a character in a string. String indices begin at 1.

CHAR (integer) string (string) index (integer)

Returns a character from a string. String indicies begin at 1.

COS_ (float) theta (float)

Returns cosine of theta. Theta should be in degrees.

DELE (command) variable_name (string)

Deletes the specified EAME variable.

DELG (command) variable_name (string)

Deletes the specified GAME variable.

DELN (command) variable_name (anything)

Deletes the specified NAME variable on TARG.

DIVV (command) var (variable) div (decimal)

Divides a variable by an integer or float, so var = var / div. Uses integer division if both numbers are integers, or floating point division  
otherwise.

EAME (variable) variable_name (string)

Very similar to GAME variables only they aren't saved or loaded with the world; they keep their value between worlds for one session of the engine. 
The E in EAME stands for for Engine. See the table of engine Eame Variables.

EAMN (string) previous (string)

Enumerates through EAME variable names, roughly as GAMN does through GAME variables. Start and end with an empty string.

FTOI (integer) number_to_convert (float)

Converts a floating-point value into its integer equivalent.

GAME (variable) variable_name (string)

A game variable is a global variable which can be referenced by name.
   eg: SETV GAME "pi" 3.142
Game variables are stored as part of the world and so will be saved out in the world file. If a script uses a non-existant game variable, that 
variable will be created automatically (with value integer zero). Agents, integers, floats and strings can be stored in game variables. Variable names 
are case sensitive. When a new world is loaded, all the game variables are cleared.
There are some conventions for the variable names:
engine_ for Creatures Engine
cav_ for Creatures Adventures
c3_ for Creatures 3
It's important to follow these, as 3rd party developers will just use whatever names they fancy. DELG deletes a game variable. See also the table of 
engine Game Variables.

GAMN (string) previous (string)

Enumerates through game variable names. Pass in an empty string to find the first one, and then the previous one to find the next. Empty string is 
returned at the end.

GNAM (string)

Returns the game name. For example "Creatures 3".

ITOF (float) number_to_convert (integer)

Converts an integer value into its floating-point equivalent.

LOWA (string) any_old (string)

Converts the given string into all lower case letters.

MAME (variable) variable_name (anything)

Machine variable version of NAME. Accesses the same variables, only via OWNR rather than TARG. This is the same difference as between MVxx and OVxx.

MODU (string)

Returns a string listed the loaded modules, and the display engine type. You can use SINS to parse this for particular values.

MODV (command) var (variable) mod (integer)

Gives the remainder (or modulus) when a variable is divided by an integer, so var = var % mod. Both values should to be integers.

MULV (command) var (variable) mul (decimal)

Multiplies a variable by an integer or float, so var = var * mul.

MVxx (variable)

MV00 to MV99 are variables specific to an agent. They are read from OWNR, the owner agent of the current script. These are the exact same variables as 
OVxx, except read from owner not targ. If owner and targ are the same, then OV23 is MV23, for example.

NAME (variable) variable_name (anything)

This is a named variable, similar to a GAME variable, only local to the target agent. See also MAME. The "name" of the variable is not limited to 
strings, but can be anything stored in a variable. i.e. integer, float, string, even an agent.

NAMN (command) previous (variable)

Enumerates through NAME variable names, roughly as GAMN does through GAME variables. Start and end with an empty string.

NEGV (command) var (variable)

Reverse the sign of the given integer or float variable, so var = 0 - var.

NOTV (command) var (variable)

Peform a bitwise NOT on an integer variable.

ORRV (command) var (variable) value (integer)

Peform a bitwise OR on an integer variable, so var = var | value.

OVxx (variable)

OV00 to OV99 are variables specific to an agent. They are read from TARG, the target agent. You can also access these same variables via owner using 
MVxx.

RAND (integer) value1 (integer) value2 (integer)

Returns a random integer between value1 and value2 inclusive of both values. You can use negative values, and have them either way round.

READ (string) catalogue_tag (string) offset (integer)

Returns a string from the catalogue. This is used for localisation. offset 0 is the first string after the TAG command in the catalogue file. See  
also  REAN and WILD.

REAF (command)

Refreshes the catalogue from files on disk, from the main catalogue directory and the world catalogue directory. These are normally read in at 
startup, when a new world is read in, or when the PRAY resources system installs a catalogue file. Use while developing CAOS programs to refresh the 
catalogue as you add entries.

REAN (integer) catalogue_tag (string)

Returns the number of entries in the catalogue for the given tag. For the same tag, you can READ values from 0 to one less than REAN returns.

REAQ (integer) catalogue_tag (string)

Returns 1 if the catalogue tag is present, 0 if not.

SETA (command) var (variable) value (agent)

Stores a reference to an agent in a variable.

SETS (command) var (variable) value (string)

Sets a variable to a string value.

SETV (command) var (variable) value (decimal)

Stores an integer or float in a variable.

SINS (integer) main (string) index_to_search_from (integer) search (string)

Looks for the search string as an exact substring of the main string (string in string). Starts searching at the given index into the main string - 
to  find the first occurence, set this to 1. String indices begin at 1. Returns the index of the position of the substring, if found, or -1 otherwise. 
The search is case sensitive - use UPPA and LOWA to convert all strings first, for a case insensitive search.

SIN_ (float) theta (float)

Returns sine of theta. Theta should be in degrees.

SQRT (float) value (float)

Calculates a square root.

STOF (float) value (string)

Converts a string in decimal to a floating point number. Characters in the string after an initial number are quietly ignored. If there is no obvious 
number then zero is returned.

STOI (integer) value (string)

Converts a string in decimal to an integer. Characters in the string after an initial number are quietly ignored. If there is no obvious number then  
zero is returned.

STRL (integer) string (string)

Returns the length of a string.

SUBS (string) value (string) start (integer) count (integer)

Slices up a string, returning the substring starting at position start, with length count. String indices begin at 1.

SUBV (command) var (variable) sub (decimal)

Subtracts an integer or float from a variable, so var = var - sub.

TAN_ (float) theta (float)

Returns tangent of theta. Theta should be in degrees. Watch out for those nasty discontinuities at 90 and 270.

TARG (command) agent (agent)

This sets the TARG variable to the agent specified.

TYPE (integer) something (anything)

Determines the type of a variable. The type is one of the following:
0 - integer
1 - floating-point
2 - string
3 - simple agent
4 - pointer agent
5 - compound agent
6 - vehicle
7 - creature
ERROR codes for agents:
-1 - NULL agent handle
-2 - Unknown agent - you should never get this

UFOS (string)

This returns the equivalent of "uname -a" on compatible systems, or a description of your operating system on others. This is a descriptive string and 
should not be taken as fixed format, or parseable.

UPPA (string) any_old (string)

Converts the given string into all upper case letters.

VAxx (variable)

VA00 to VA99 are local variables, whose values are lost when the current script ends.

VMJR (integer)

Returns the major version number of the engine.

VMNR (integer)

Returns the minor version number of the engine.

VTOS (string) value (decimal)

Converts an integer or float into a string in decimal.

_P1_ (variable)

Returns the first parameter sent to a script.

_P2_ (variable)

Returns the second parameter sent to a script.