scripting:reference:system_functions
This is an old revision of the document!
Table of Contents
System Functions
The scripting engine provides a set of 'System Functions', usually preceded by sys. Below is the complete list of system functions currently available.
(Note also the list of special system control functions which includes special cases like the 'Sleep' function etc)
Text Functions
Player Information
Inventory and Wealth manipulation
Building Information
World map functions
ConstructionFunctions
Scripted Subgames
Building Ownership
Town information and control
Misc. other functions
Battle game Functions
BattleSetPreludeTime
BattleSetNumRounds
BattleSetRoundTime
BattleSetRoundScore
BattleSendChallenge
Maths Functions
sysRand
Format | sysRand ( [MAX_NUM] ) |
---|---|
Description | Returns a random number between 1 and the value specified |
Example | $var = Rand(500) |
sysSin
Format | sysSin ( [ANGLE], [SCALE] ) |
---|---|
Description | Returns a sine value |
Parameters | Angle - 0 to 360 degrees |
Scale - Scale applied to the result from the sine function (which normally returns a value from -1 to 1 | |
Returns | Scaled sine value |
Example:
Event( "Custom", "TreeCircle" ) { $angle = 0 while ( $angle < 360 ) { $posX = sysSin( $angle, 100 ) $posY = sysCos( $angle, 100 ) $posX += $gPlayerWorldX $posY += $gPlayerWorldY *addtree 1,$posX,$posY $angle += 36 } }
sysCos
Format | sysCos ( [ANGLE], [SCALE] ) |
---|---|
Description | Returns a cosine value |
Parameters | Angle - 0 to 360 degrees |
Scale - Scale applied to the result from the cosine function (which normally returns a value from -1 to 1 | |
Returns | Scaled cosine value |
Example: See sysSin above
sysGetDist
Format | sysGetDist ( [X1], [Y1], [X2], [Y2] ) |
---|---|
Description | Calculates the distance between two points |
Parameters | Point 1 X,Y |
Point 2 X,Y | |
Returns | Distance |
Example:
Event( "AccessBuilding", "1" ) { $dist = sysGetDist( $gPlayerWorldX, $gPlayerWorldY, $gBuildingWorldX, $gBuildingWorldY ) *msg %PLAYER% You accessed the building from $dist cm away }
Misc other functions
sysRealTime
Format | sysRealTime ( [Type] ) |
---|---|
Description | Returns details of the current real time (according to the server clock) |
Parameters | Type field specifying the date or time to fetch |
Returns | Depending on the type field: |
Year - returns the current year (e.g. 2014) | |
Month - returns the current month number (1 to 12) | |
Day - returns the current day number (1 to 31) | |
Hour - returns the current hour (0 to 23) | |
Minute - returns the current minute (0 to 59) | |
Second - returns the current second (0 to 59) | |
UnixTime - number of seconds passed since 1st Jan, 1970 |
Example:
Event( "UseItem", "Tea" ) { $hour = sysRealTime( "Hour" ) if ( $hour < 18 ) { *msg %PLAYER% Tea can only be used at tea-time (6pm - 8pm) } else if ( $hour >= 20 ) { *msg %PLAYER% Tea can only be used at tea-time (6pm - 8pm) } else { *notifylarge %PLAYER% Tea-time! } }
sysRaceIsActive
TBD
scripting/reference/system_functions.1580294586.txt.gz · Last modified: 2020/01/29 04:43 by mit