Difference between revisions of "Category:Variables"

From SphereWiki
Jump to: navigation, search
m (Properties and Functions)
(update to Qval)
Line 81: Line 81:
 
|-
 
|-
 
| [[QVAL]] ''expression''? ''value_true'':''value_false'' || R || Evaluates an expression and returns ''value_true'' if the result is true, otherwise returns ''value_false''.
 
| [[QVAL]] ''expression''? ''value_true'':''value_false'' || R || Evaluates an expression and returns ''value_true'' if the result is true, otherwise returns ''value_false''.
 +
There is another variant of QVAL in the [[Intrinsic Functions]] category.
 
|-
 
|-
 
| [[R]]''x'' || R || Returns a random number between 0 and ''x - 1''.
 
| [[R]]''x'' || R || Returns a random number between 0 and ''x - 1''.

Revision as of 05:53, 19 January 2013

References

The following table lists all object references that are available from any script.

Name Read/Write Description
DB R Gets the server's database object.
FILE R Gets the server's file object.
I R Gets the current object.
LIST R Gets the server's list object.
NEW RW Gets or sets the last character or item created on the server.
OBJ RW Gets or sets a reference to a character or item
SRC R Gets the source character of an event.
UID.object_uid R Gets a reference to the character or item with the specified UID.


Properties and Functions

The following table lists all properties and functions that are available from any script.


Name Read/Write Description
ASC text R Converts text into a series of ASCII values.
BETWEEN min, max, numerator, denominator R Returns the value that's numerator/denominator between min and max
BETWEEN2 min, max, numerator, denominator R Returns the value that's numerator/denominator between max and min
CHR ascii_code R Returns the character represented by the given ASCII code.
CLEARVARS prefix W Removes all server VARs whose name start with prefix.
CLRBIT value, bit R Returns the value of value with bit not set.
Dproperty_or_function R Forces a property or function to return a decimal value.
DEFMSG.name W Sets the value of a DEFMESSAGE. (see sphere_msgs.scp)
EXPLODE separators, text R Splits text by the given separator characters.
EVAL expression R Evaluates an expression and returns the result as an integer.
FEVAL expression R Evaluates an expression and returns the result as an integer, supports floating point values.
FHVAL expression R Evaluates an expression and returns the result as a hexadecimal value, supports floating point values.
FLOATVAL expression R Evaluates an expression and returns the result as a floating point value.
FVAL expression R Evaluates an expression and formats the result with a single decimal point. ("1000" becomes "100.0")
ref.GETREFTYPE R Returns a code representing what type of object ref is.
HVAL expression R Evaluates an expression and returns the result as a hexadecimal value.
ISBIT value, bit R Returns non-zero if bit is set in value.
ISEMPTY value R Returns 1 if value is empty/blank text.
ISNUM value R Returns 1 if value is a numeric value.
LISTCOL R Returns the alternating colour in webpage tables.
MD5HASH text R Returns an MD5 hash for text.
MULDIV num, mul, div R Returns (num * mul) / div.
NEWDUPE object_uid W Clones the character or item with the specified UID.
NEWITEM item_defname, amount, container, equip W Creates a new item.
NEWNPC character_defname W Creates a new character.
QVAL expression? value_true:value_false R Evaluates an expression and returns value_true if the result is true, otherwise returns value_false.

There is another variant of QVAL in the Intrinsic Functions category.

Rx R Returns a random number between 0 and x - 1.
Rx, y R Returns a random number between x and y.
SETBIT value, bit R Returns the value of value with bit set.
SHOW property_or_function W Displays the returned value from a property or function to SRC.
STRARG text R Returns the first word from text.
STREAT text R Removes the first word from text and returns the remaining text.
STRPOS position character text R Returns the position of a character within the text, starting from position.
STRREGEXNEW pattern, text R Returns 1 if text matches a regular expression pattern.
STRREVERSE text R Returns text, after reversing its characters.
STRSUB position, count, text R Extracts count characters from text, starting from position.
STRTOLOWER text R Returns text in lowercase.
STRTOUPPER text R Returns text in uppercase.
STRTRIM text R Removes whitespace (i.e. spaces, tabs) from the start and end of text.
SYSCMD command, arg1, arg2... R Executes a system command on the server and waits for it to complete.
Note: Requires OF_FileCommands to be enabled in Sphere.ini
SYSSPAWN command, arg1, arg2... R Executes a system command on the server and does not wait for it to complete.
Note: Requires OF_FileCommands to be enabled in Sphere.ini
UVAL expression R Evaluates an expression and returns the result as an unsigned integer.
VAR.name RW Gets or sets the value of a VAR.

This category currently contains no pages or media.