backIndex

Xelagot action script

Numeric variables and operations

This header includes all operations that result in a numeric value, and that must be assigned to a numeric variable of type %a. This information is split in two tables: one for integers and one for real numbers. A third table lists the conditional statements involving integers and real numbers.

Variables shown in black may be substituted by literal values, variables shown in red are assigned the result of the operation, variables in green may not be substituted by their literal equivalents.

ASSIGNMENT
%a = %b
%a = $b
simple assignement of %b to %a. Variable %b can be substituted by a numeric value, as in %a=3.7, or by a string variable consisting of one number. See Variables for a fuller explanation.
StringFromReal $a %b [%d] extracts the floating point value in %b and assigns it in string format to $a. You may also indicate the number of decimals with an optional %d.
StringFromInt $a %b extracts the integer value in %b (rounding off to the nearest integer) and assigns it in string format to $a.
INTEGER OPERATIONS
Inc %a rounds off %a to the nearest integer and increases its value by one
Dec %a rounds off %a to the nearest integer and decreases its value by one
IntAdd %a %b %c rounds off %b and %c to the nearest integer, adds them and assigns this value to %a
IntSbt %a %b %c rounds off %b and %c to the nearest integer, subtracts %c from %b and assigns this value to %a
IntMul %a %b %c rounds off %b and %c to the nearest integer, multiplies them and assigns this value to %a
IntDiv %a %b %c rounds off %b and %c to the nearest integer, divides %b by %c applying integer division and assigns this value to %a. Division by zero will stop the assignment
Round %a %b rounds off %b to the nearest integer and assigns this value to %a
Mod %a %b %c rounds off %b and %c to the nearest integer, takes the absolute value of %c and, if %b is negative, adds it to %b until %b is not negative, then calculates %b modulo %c and assigns this value to %a. If %c evaluates to zero, the result will be zero. The difference with ModNeg lies in the treatment of negative values of %b. Examples:
mod %a 11 8 will assign 3 to %a
mod %a -11 8 will assign 5 to %a
ModNeg %a %b %c rounds off %b and %c and, takes the absolute values of %b and %c and calculates %b modulo %c, then restores the original sign of %b and assigns to %a. If %c evaluates to zero, the result will be zero. The difference with Mod lies in the treatment of negative values of %b. Examples:
modneg %a 11 8 will assign 3 to %a
modneg %a -11 8 will assign -3 to %a
ModOne %a %b %c rounds off %b and %c to the nearest integer, subtracts 1 from %b, takes the absolute value of %c and, if %b is negative, adds it to %b until %b is not negative, then calculates (%b modulo %c) + 1 and assigns this value to %a. If %c evaluates to zero, the result will be one. Treats negative values similarly to Mod. Examples:
modone %a -1 7 will assign 6 to %a
modone %a 0 7 will assign 7 to %a
modone %a 1 7 will assign 1 to %a
modone %a 2 7 will assign 2 to %a
modone %a 3 7 will assign 3 to %a
...
modone %a 7 7 will assign 7 to %a
modone %a 8 7 will assign 1 to %a
RandInt %a %b %c gives a random integer number between %b and %c and assigns its value to %a. To get random real numbers, use Random %a %b %c.
These statements involve strings. See also String operations.
Length %a $b stores in the numeric variable %a the length of string $b.
Pos %u $b $c [%i] stores in the numeric variable %u the position of substring $b in string $c (case insensitive). The optional parameter %i indicates the position in string $c where the search starts, defaults to 1. If search fails, then %u is 0. Example:
Pos %u "hel" "say Hello, help!"
will put %u equal to 5, and
Pos %u "hel" "say Hello, help!" 6
will make %u equal to 12
PosExact %u $b $c [%i] stores in the numeric variable %u the position of substring $b in string $c (case sensitive). The optional parameter %i indicates the position in string $c where the search starts, defaults to 1. If search fails, then %u is 0.
The statements involving date and time have coresponding string and date-time equivalents. See String operations and Date and time operations. Unless otherwise stated or implemented in the script, time values are in VRT.
GetYear %a
GetLocalYear %a
gets the current year and stores it in the numeric variable %a. (VRT or Local Time)
GetYear %a !b gets the year stored in date-time variable !b and stores it in the numeric variable %a.
GetMonth %a
GetLocalMonth %a
gets the current month and stores it in the numeric variable %a. (VRT or Local Time)
GetMonth %a !b gets the month stored in date-time variable !b and stores it in the numeric variable %a.
GetDay %a
GetLocalDay %a
gets the current day of the month and stores it in the numeric variable %a. (VRT or Local Time)
GetDay %a !b gets the day of the month stored in date-time variable !b and stores it in the numeric variable %a.
GetHour %a
GetLocalHour %a
gets the current hour and stores it in the numeric variable %a. (VRT or Local Time)
GetHour %a !b gets the hour stored in date-time variable !b and stores it in the numeric variable %a.
GetMinute %a
GetLocalMinute %a
gets the current minutes and stores it in the numeric variable %a. (VRT or Local Time)
GetMinute %a !b gets the minutes stored in date-time variable !b and stores it in the numeric variable %a.
GetSecond %a
GetLocalSecond %a
gets the current seconds and stores it in the numeric variable %a. (VRT or Local Time)
GetSecond %a !b gets the seconds stored in date-time variable !b and stores it in the numeric variable %a.
GetDayOfWeek %a !b gets the day of the week of the date stored in date-time variable !b and stores it in the numeric variable %a. 1 = Sunday, 2 = Monday, ... 7 = Saturday. Tip: after adding or subtracting days to this value, use ModOne %a %a 7 to reduce %a back to the correct range of 1 to 7.
GetDifSecond %a !b
GetLocalDifSecond %a !b
gets the absolute value of the difference in seconds between Now and the time stored in !b and assigns it in the numeric variable %a. (Now is VRT or Local Time, use the appropriate set according to what is stored in !b)
GetDifSecond %a !b !c gets the absolute value of the difference in seconds between !b and !c and assigns it in the numeric variable %a.
The statements involving location. person and object have corresponding string, location, person and object equivalents. See String operations, Location operations, Person operations and Object operations.
GetBotNumber %a
GetBotNumber %a %n
gets the bot's number (1 upwards) and stores it in %a. If %n is specified, it gets the number of bot number %n; this allows you to check whether %n is out of range or not: if %a gets assigned the same number as %n, %n is not out of range. Bots are numbered from 1 upwards, numbers out of range default to the bot running the script. For X1 xelagots, valid numbers are: 1, 2 and 3.
GetSession %a
GetSession %a %n
gets the bot's session number and stores it in %a. If %n is specified, it gets the session number of bot number %n. Bots are numbered from 1 upwards, numbers out of range default to the bot running the script. For X1 xelagots, valid numbers are: 1, 2 and 3.
GetSession %a &b gets the session number in &b and stores it in %a.
GetCitnum %a gets the bot's citizen login number.
GetCitnum %a %n gets bot number %n's citizen login number. %n starts at 1, numbers out of range default to the bot running the script.
GetCitnum %a &b
GetCitnum %a ~b
gets the citizen number in person variable &b or object variable ~b and stores it in %a.
GetPrivs %a &b gets the privs used by person &b and stores it in %a. Privs are = 0 if they are unknown, = Citnum if they are known and the person uses no privs or uses his/her own, any other positive number indicates the citizen number of the privs used by the person. Not yet available, expected in AW version 3.1
GetAvatar %a gets the bot's avatar number.
GetAvatar %a %n gets bot number %n's avatar number. %n starts at 1, numbers out of range default to the bot running the script.
GetAvatar %a &b gets the avatar number in &b and stores it in %a.
GetGesture %a gets the bot's current gesture number.
GetGesture %a %n gets bot number %n's current gesture number. %n starts at 1, numbers out of range default to the bot running the script.
GetGesture %a &b gets the gesture number in &b and stores it in %a.
GetCellNS %a
GetCellNS %a %n
gets the bot's cellNS (CellZ) coordinate (in integer decametres). If %n is specified, it gets the cellNS of bot number %n. Bots are numbered from 1 upwards, numbers out of range default to the bot running the script. For X1 xelagots, valid numbers are: 1, 2 and 3.
GetCellNS %a @b
GetCellNS %a &b
GetCellNS %a ~b
gets the CellNS (CellZ) coordinate (in integer decametres) stored in location variable @b, in person variable &b or in object variable ~b.
GetCellWE %a
GetCellWE %a %n
gets the bot's cellWE (CellX) coordinate (in integer decametres). If %n is specified, it gets the cellWE of bot number %n. Bots are numbered from 1 upwards, numbers out of range default to the bot running the script. For X1 xelagots, valid numbers are: 1, 2 and 3.
GetCellWE %a @b
GetCellWE %a &b
GetCellWE %a ~b
gets the CellWE (CellX) coordinate (in integer decametres) stored in location variable @b, in person variable &b or in object variable ~b.
GetTimestamp %a ~b gets the timestamp in Unix integer time format in ~b and stores it in %a. If you need the timestamp in date-time format, use GetTimestamp !a ~b.
GetObjectNumber %a ~b gets the object number (integer) in ~b and stores it in %a. This object number is assigned by the SDK when it sends the object to be built in the world (at the moment it is sent to the server), and is part of the string retrieved with GetObjectID $a ~b (see string variables and operations).

REAL (FLOTING POINT) OPERATIONS
Abs %a %b assigns the absolute value of %b to %a.
Add %a %b %c adds %b and %c and assigns this value to %a.
Sbt %a %b %c subtracts %c from %b and assigns this value to %a.
Mul %a %b %c multiplies %b and %c and assigns this value to %a.
Div %a %b %c divides %b by %c and assigns this value to %a. Division by zero will stop the assignment.
Square %a %b squares %b and assigns this value to %a.
Root %a %b takes the square root of the absolute value of %b and assigns this value to %a
Power %a %b %e raises %b to the power of %e and assigns this value to %a. Supports non integer values of %e.
Log10 %a %b assigns base 10 logarithm of %b to %a.
Log2 %a %b assigns base 2 logarithm of %b to %a.
Ln %a %b assigns natural logarithm of %b to %a.
LogN %a %b %c assigns base %b logarithm of %c to %a.
LnXP1 %a %b assigns natural logarithm of %b+1 to %a. Use when value of %b is close to 0.
Exp %a %b assigns exponential of %b to %a.
Hypot %a %b %c assigns to %a the value of the square root of the sum of the squares of %b and %c. Equivalent to writing:
square %d %b
square %e %c
add %a %d %e
root %a %a
Max %a %b %c compares %b and %c and assigns the larger value to %a
Min %a %b %c compares %b and %c and assigns the smaller value to %a.
Random %a %b %c gives a random number between %b and %c and assigns its value to %a. If you work with integers, use RandInt %a %b %c.
RandG %a %mean %std_dev gives a random number for the Gaussian distribution about the Mean using the values of %mean and %std_dev (standard deviation) and assigns it to %a.
Cos %a %b assigns to %a the cosine of angle %b (in degrees).
Sin %a %b assigns to %a the sine of angle %b (in degrees).
Tan %a %b assigns to %a the tangent of angle %b (in degrees). Overflow results in assignment of zero.
Cotan %a %b assigns to %a the cotangent of angle %b (in degrees). (cotangent = 1/tangent). Overflow results in assignment of zero.
ArcCos %a %b assigns to %a the arccosine of %b, the result is in degrees (0 to 360).
ArcSin %a %b assigns to %a the arcsine of %b, the result is in degrees (0 to 360).
ArcTan %a %b assigns to %a the arctangent of %b, the result is in degrees (0 to 360). The quadrant is undecided. See ArcTan2.
ArcTan2 %a %b %c assigns to %a the arctangent of the division of %b by %c, the result is in degrees (0 to 360). The quadrant is correct.
Cosh %a %b assigns to %a the hyperbolic cosine of angle %b (in degrees).
Sinh %a %b assigns to %a the hyperbolic sine of angle %b (in degrees).
Tanh %a %b assigns to %a the hyberbolic tangent of angle %b (in degrees). Overflow results in assignment of zero.
ArcCosh %a %b assigns to %a the arccosh of %b, the result is in degrees (0 to 360).
ArcSinh %a %b assigns to %a the arcsinh of %b, the result is in degrees (0 to 360).
ArcTanh %a %b assigns to %a the arctanh of %b, the result is in degrees (0 to 360).
PolFromRec %a %r %x %y changes the cartesian coordinates %x and %y to polar coordinates a (angle in degrees) and r (radius), and assigns the values a to %a and r to %r. The values of %r, %x and %y must be in the same units of length. Assign a default value to angle %a before calling PolFromRec: when %x and %y are both zero, the angle is undefined, and the function will not modify the value of angle %a and will leave it unassigned.
RecFromPol %x %y %a %r changes the polar coordinates %a (angle in degrees) and %r (radius) to cartesian x and y, and assigns the values x to %x and y to %y. The values of %r, %x and %y must be in the same units of length.
Distance %a @p @q
@p may be substituted by &p and ~p,
@q may be substituted by &q and ~q.
gets the spatial distance in metres between locations @p and @q and assigns it to %a. Its value is always positive. You may also compare person and objects variables.
DistanceH %a @p @q
@p may be substituted by &p and ~p,
@q may be substituted by &q and ~q.
gets the horizontal distance in metres between locations @p and @q and assigns it to %a. Its value is always positive. You may also compare person and objects variables.
DistanceV %a @p @q
@p may be substituted by &p and ~p,
@q may be substituted by &q and ~q.
gets the difference in altitude in metres between locations @p and @q and assigns it to %a. Its value is positive if @q is higher than @p. You may also compare person and objects variables.
DistanceNS %a @p @q
@p may be substituted by &p and ~p,
@q may be substituted by &q and ~q.
gets the difference in metres between the NS coordinates of locations @p and @q and assigns it to %a. Its value is positive if @q is North of @p. You may also compare person and objects variables.
DistanceWE %a @p @q
@p may be substituted by &p and ~p,
@q may be substituted by &q and ~q.
gets the difference in metres between the WE coordinates of locations @p and @q and assigns it to %a. Its value is positive if @q is West of @p. You may also compare person and objects variables.
AWDistanceNS %a @p @q
@p may be substituted by &p and ~p,
@q may be substituted by &q and ~q.
gets the difference in AW units between the NS coordinates of locations @p and @q and assigns it to %a. Its value is positive if @q is North of @p. This value should not be used in calculations involving metres. You may also compare person and objects variables.
AWDistanceWE %a @p @q
@p may be substituted by &p and ~p,
@q may be substituted by &q and ~q.
gets the difference in AW units between the WE coordinates of locations @p and @q and assigns it to %a. Its value is positive if @q is West of @p. This value should not be used in calculations involving metres. You may also compare person and objects variables.
The statements involving location. person and object have corresponding string, location, person and object equivalents. See String operations, Location operations, Person operations and Object operations.
GetNS %a
GetNS %a %n
gets the bot's NS coordinate (in metres). If %n is specified, it gets the NS coordinate of bot number %n. Bots are numbered from 1 upwards, numbers out of range default to the bot running the script. For X1 xelagots, valid numbers are: 1, 2 and 3.
GetNS %a @b
GetNS %a &b
GetNS %a ~b
gets the NS coordinate (in metres) stored in location variable @b, in person variable &b or in object variable ~b.
GetWE %a
GetWE %a %n
gets the bot's WE coordinate (in metres). If %n is specified, it gets the WE coordinate of bot number %n. Bots are numbered from 1 upwards, numbers out of range default to the bot running the script. For X1 xelagots, valid numbers are: 1, 2 and 3.
GetWE %a @b
GetWE %a &b
GetWE %a ~b
gets the WE coordinate (in metres) stored in location variable @b, in person variable &b or in object variable ~b.
GetAltitude %a
GetAltitude %a %n
gets the bot's Altitude (in metres). If %n is specified, it gets the Altitude of bot number %n. Bots are numbered from 1 upwards, numbers out of range default to the bot running the script. For X1 xelagots, valid numbers are: 1, 2 and 3.
GetAltitude %a @b
GetAltitude %a &b
GetAltitude %a ~b
gets the altitude (in metres) stored in location variable @b, in person variable &b or in object variable ~b.
GetRotation
see GetYaw, its new Xelagot 3.3 name. The older GetRotation statements still work in the 3.3 bot.
3.3 statements

GetYaw %a
GetYaw %a %n
gets the bot's Yaw angle (in degrees, + is anticlockwise). If %n is specified, it gets the Yaw of bot number %n. Bots are numbered from 1 upwards, numbers out of range default to the bot running the script. For X1 xelagots, valid numbers are: 1, 2 and 3.
3.3 statements

GetYaw %a @b
GetYaw %a &b
GetYaw %a ~b
gets the Yaw angle (in degrees) stored in location variable @b, in person variable &b or in object variable ~b.
3.3 statements

GetTilt %a
GetTilt %a %n
gets the bot's Tilt angle (in degrees, + is anticlockwise). If %n is specified, it gets the Tilt of bot number %n. Bots are numbered from 1 upwards, numbers out of range default to the bot running the script. For X1 xelagots, valid numbers are: 1, 2 and 3.
3.3 statements

GetTilt %a @b
GetTilt %a &b
GetTilt %a ~b
gets the Tilt angle (in degrees) stored in location variable @b, in person variable &b or in object variable ~b.
3.3 statements

GetRoll %a
GetRoll %a %n
gets the bot's Roll angle (in degrees, + is anticlockwise). If %n is specified, it gets the Roll of bot number %n. Bots are numbered from 1 upwards, numbers out of range default to the bot running the script. For X1 xelagots, valid numbers are: 1, 2 and 3.
3.3 statements

GetRoll %a @b
GetRoll %a &b
GetRoll %a ~b
gets the Roll angle (in degrees) stored in location variable @b, in person variable &b or in object variable ~b.

CONDITIONAL STATEMENTS FOR NUMERALS

See Conditional Statements for a general explanation.

Please note: within these statements, elements must be clearly separated by spaces. This includes the operators!

for integers (whole numbers)
IfInt %a operarator %b statement1

IfIsLeapYear %a statement1

IfIsNotLeapYear %a statement1


for real numbers
IfReal %a operarator %b statement1

%a and %b can be variables or numeric values. An optional
Else statement2
may follow on the next line.
the operator may be one of the following:
= equal
<> not equal
> greater than
< smaller than
>=
or
=>
greater or equal
<=
or
=<
smaller or equal


backIndex