Valarin
DGScripts: Variables
V A R I A B L E S

Variables appear as a name surrounded by '%'s, such as

%actor%
Before a command is processed, the line is scanned and any variables are replaced. First the list of local variables are checked to see if the variable is there. If not, the global variables are checked. If a match is still not found, a list of 'built in' variables (ones not declared by the script) are checked. If no match is found, the variable is replaced with an empty string (the variable is removed from the line, and nothing added in its place). Two '%'s in a row will be interpreted as a single '%'.

There are two types of variables, local and global. All local variables are deleted when a trigger finishes executing, and can only be used by the trigger. Global variables remain until removed with unset, or the script is removed.

Variable Fields

A field of a variable can also retrieved, based on their type. To get a field, a notation of %variable.field% is used. The valid fields for each type of game object are listed below. If fields are needed that are not yet present, talk to an implementor about having them added.
V A R I A B L E   F I E L D S :   C H A R A C T E R S
alias
The list of aliases of the character.
align
The numeric alignment of the character.
canbeseen
True if the character can be seen by the mob (always true for non-mob triggers).
cha
The character's charisma.
class
The character's class, as a string.
con
The character's constitution.
dex
The character's dexterity.
eq
The object residing in a given spot.
fighting
The character this character is fighting, or "NULL".
gold
The amount of gold on the character.
hit
The character's current hit points.
id
The character's ID num.
int
The character's intelligence.
level
The character's current level.
mana
The character's current mana points.
master
The character's group leader/master, or "NULL".
maxhit
The character's maximum hit points.
maxmana
The character's maximum mana points.
maxmove
The character's maximum movement points.
move
The character's current movement points.
name
The character's name (the short description for mobs).
race
The character's race, as a string.
room
The room vnum the character is in.
sex
The character's sex, as a string (MALE, FEMALE, or NEUTRAL).
skill
The percentage known of the specified spell/skill.
str
The character's strength.
stradd
The character's strength addition (if str is 18).
vnum
The character's virtual number. -1 for PCs.
wis
The character's wisdom.
V A R I A B L E   F I E L D S :   O B J E C T S
id
The ID num of the object.
name
The list of key words of the object.
shortdesc
The name of the object that players see.
timer
The value of the timer on the object.
type
The type of object, such as WAND, ARMOR, or KEY.
val0
Value 0 of the object, defined in values.doc.
val1
Value 1 of the object, defined in values.doc.
val2
Value 2 of the object, defined in values.doc.
val3
Value 3 of the object, defined in values.doc.
vnum
The virtual number of the object.
V A R I A B L E   F I E L D S :   R O O M S
name
The name of the room.
north
The list of flags affecting the north exit.
east
The list of flags affecting the east exit.
south
The list of flags affecting the south exit.
west
The list of flags affecting the west exit.
up
The list of flags affecting the upward exit.
down
The list of flags affecting the downward exit.
northeast
The list of flags affecting the northeast exit.
northwest
The list of flags affecting the northwest exit.
southeast
The list of flags affecting the southeast exit.
southwest
The list of flags affecting the southwest exit.
vnum
The room's vnum.
S P E C I A L   V A R I A B L E S
self
The mob, item, or room running the script. Normal fields may be used with this.
hour
The current mud hour, 0 to 23.
random
This variable returns a number between 1 and the field value. For example, %random.10% would be a value between 1 and 10.
speech
This variable is set to the complete phrase spoken by an actor that triggers a speech trigger.
Variables are case insensitive.
Table of Contents, Previous Chapter, Next Chapter
Builder's Information | Home