Open new window
Last update:

OasisOLC and Deaths Gate script reference

Variables

Important to know about variables in DG scripts:
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. A proper global match must have a zero context or the current context of the script. (When a script starts running, its context is 0. The script 'context' command may be used to change context.) 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.

Global variables also have a context associated with them. By default, the context is 0. Any global being referenced with a context of zero will be seen. Through the context value command, a script may set its context to any integer; Globals created are always assigned the current script context. When a global is referenced, if it's context is not 0 or the current context of the script, it will not be seen. This technique allows, among other things, arrays of globals to be created by using a series of contexts as indexes. Also, it allows globals to be associated with a specific character, room, or object in the game, by using the id of the target as the context.

 

Variable Fields

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

A field of a variable can also be 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 me (Welcor) about having them added. Some fields have subfields, that may give an option to alter that field, or give more detailed information. The notation of a subfield is %variable.field(subfield)%.

As a new addition (thx to Jamie Nelson for that one), it is now possible to chain fields as well as to use variables within subfields like this: %object.worn_by.skillset("magic missile" %object.val2%)% .

Characters 

In this context, %char% represents a variable for a character,

%obj% is a variable for an object, and %room% is a variable for a room.

When using field:

The variable returns:

%char.alias%

The list of aliases of the mob or the character name for players.

%char.align(<number>)%
%char.align%

The numeric alignment of the character.
If a subfield is provided, the alignment is set to this value.
-1000 <= subfield <= 1000.

%char.affect(<spellname>)%

True if the character is affected by the spell <spellname>.
Example: %self.affect(bless)%

%char.canbeseen%

True if the character can be seen by the mob.
Always returns true for non-mob triggers.

%char.cha%
%char.cha(<value>)%

The character's charisma.
If a subfield is provided, the value is added to the current stat.

%char.class%

The character's class, as a string.

%char.con%
%char.con(<value>)%

The character's constitution.
If a subfield is provided, the value is added to the current stat.

%char.dex%
%char.dex(<value>)%

The character's dexterity.
If a subfield is provided, the value is added to the current stat.

%char.exp%
%char.exp(<amount>)%

The character's experience points.
If a subfield is provided, the value is added to the current experience.
Currently the limit is set to 1000 exp. Do not abuse this feature!

%char.eq(<position>)%
%char.eq(*)%

An object variable for the object equipped inposition, if any.
The specified position may be either a position number (0-17) or the name of the location:
light, rfinger, lfinger, neck1, neck2, body, head, legs, feet, hands, arms, shield, about, waist, rwrist, lwrist, wield, hold
When called with * as subfield, it will return whether or not the character is wearing anything at all.

%char.fighting%

A variable for the target this character is currently fighting, or an empty return.

%char.follower%

A variable for the first character following this character, or an empty return.

%char.gold%
%char.gold(<amount>)%

The amount of gold on the character.
If a subfield is used, the amount is added to the current gold amount.
Do not abuse this feature!

%char.has_item(<object variable>)%
%char.has_item(<object vnum>)%
%char.has_item(<object name>)%

True if character has an object with the correct characteristics.

%char.hisher%

"his", "her" or "its", depending on the gender of the character.

%char.heshe%

"he", "she" or "it", depending on the gender of the character.

%char.himher%

"him", "her" or "it", depending on the gender of the character.

%char.id%

The unique id of the character.
This is mostly an internal value, but can be useful when you want a unique identifier.

%char.int%
%char.int(<value>)%

The character's intelligence.
If a subfield is provided, it will be added to the current stat.

%char.inventory%
%char.inventory(<object vnum>)%

An object variable pointing to the first object in the inventory, or if a subfield is given, the first item with the correct vnum.
If such an item cannot be found, the reutrn is empty.

%char.is_killer%
%char.is_killer( on | off )%

The player killer status of the character.
The subfield sets or removes the flag.

%char.is_thief%
%char.is_thief( on | off )%

The player thief status of the character.
The subfield sets or removes the flag.

%char.is_pc%

True if the character is a player.
This is the new and official way to check this.

%char.level%

The character's current level.

%char.hitp%
%char.hitp(<value>)%

The current hit points of the character.
If a value is given, it will be added to the current stat.

%char.mana%
%char.mana(<value>)%

The current mana points of the character.
If a value is given, it will be added to the current stat.

%char.move%
%char.move(<value>)%

The movement points of the character.
If a value is given, it will be added to the current stat.

%char.master%

A variable for the master of the character, or an empty return.
The master is the person the character is currently following.

%char.maxhitp%
%char.maxhitp(<value>)%

The maximum hit points of the character.
If a value is given, it will be added to the current stat.

%char.maxmana%
%char.maxmana(<value>)%

The maximum mana points of the character.
If a value is given, it will be added to the current stat.

%char.maxmove%
%char.maxmove(<value>)%

The maximum movement points of the character.
If a value is given, it will be added to the current stat.

%char.name%

The character's name (the short description for mobs).

%char.next_in_room%

A variable for the next person in the room.
An empty return if this character is the last in the room.

%char.pos%
%char.pos(<position>)%

The current position of the character.
If a subfield is provided, the characters position is changed.
Allows Sleeping, Resting, Sitting, Fighting, Standing
Thx to Christian Ejlertsen for this contribution.

%char.prac%
%char.prac(<value>)%

The number of practice sessions available to the character.
If a subfield is provided, it is added to the current amount.

%char.race%

The character's race, as a string.

%char.room%

A room variable for the room the character is in.
Older versions returned a room vnum here.

%char.sex%

The character's sex, as a string (MALE, FEMALE, or NEUTRAL).

%char.skill(<skillname>)%

The percentage of learnedness in the named skill.

%char.skillset("<skill>" <value>)%

Set the character's learnedness of skill <skill> to <value>.
This variable has no return value.
Example: %char.skillset("magic missile" 65)%

%char.str%
%char.str(<value>)%

The character's strength.
If a subfield is provided, the value is added to the current stat.

%char.stradd%
%char.stradd(<value>)%

The character's strength addition (if str is 18).
If a subfield is provided, the value is added to the current stat.

%char.saving_para%
%char.saving_para(<value>)%

The characters saving throw vs. paralysis.
If a subfield is provided, the value is added to the current stat.

%char.saving_rod%
%char.saving_rod(<value>)%

The characters saving throw vs. rods and staves.
If a subfield is provided, the value is added to the current stat.

%char.saving_petri%
%char.saving_petri(<value>)%

The characters saving throw vs. petrification.
If a subfield is provided, the value is added to the current stat.

%char.saving_breath%
%char.saving_breath(<value>)%

The characters saving throw vs. breath weapons.
If a subfield is provided, the value is added to the current stat.

%char.saving_spell%
%char.saving_spell(<value>)%

The characters saving throw vs. spells.
If a subfield is provided, the value is added to the current stat.

%char.title%
%char.title(<value>)%

The character's title. This only makes sense for PCs.
If a subfield is provided, the title is set to this value.

%char.vnum%
%char.vnum(<value>)%

The character's virtual number. -1 for PCs.
The check for %actor.vnum% != -1 is deprecated. Use %actor.is_pc% instead.
If a subfield is given, it is the equivalent of
(%char.vnum% == <value>)

%char.varexists(<var>)%

True if:
1. %char% has a script attached, and
2. the global variable <var> exists.
Otherwise, false is returned.
This is highly useful when dealing with remote vars on players.

%char.weight%

The character's weight.

%char.wis%
%char.wis(<value>)%

The character's wisdom.
If a subfield is provided, it will be added to the current stat.

%char.<global>%

If the specified field is not a recognized one, the character's script global list is searched for a matching global name. If found, its value will be returned. This can is also used to get values of vars set on players;

if %actor.varexists(testvar)%
  set testvar %actor.testvar%
end
* and then later in the script write it back:
remote testvar %actor.id%

Objects

When using field:

The variable returns:

%obj.carried_by%

A variable for the character carrying the object, or an empty return

%obj.cost%
%obj.cost(<value>)%

The cost (not rent cost) of the object.
If a value is given, it will be added to the current value.

%obj.cost_per_day%
%obj.cost_per_day(<value>)%

The rent cost of the object
If a value is given, it will be added to the current value.

%obj.contents%

A variable for the first object inside this object, or an empty return.

%obj.count%
%obj.count(<vnum>)%

The amount of objects inside this object.
If a vnum is supplied, only objects with this vnum are counted.
Note: only items in the 'top' layer are counted. Items in a bag, inside this container will not be counted.

%obj.has_in(<vnum>)%
%obj.has_in(<name>)%

True if the object contains an item with the correct characterisitics.
Note: only items in the 'top' layer are checked. Items in a bag, inside this container will not be checked.

%obj.id%

The unique id of the object.

%obj.is_inroom%

A variable for the current room of the object.
If the object is not in a room (ie. carried et al.), an empty return.

%obj.name%

The list of key words of the object - aliases.

%obj.shortdesc%

The name of the object that players see.

%obj.room%

A variable for the current room of the object.
If the object is not in a room, the room of the carrier will be used.

%obj.timer%

The current timer of the object

%obj.type%

The type of object, such as WAND, ARMOR, or KEY.

%obj.val0%

Returns the current value 0 of the object, defined here.

%obj.val1%

Returns the current value 1 of the object, defined here.

%obj.val2%

Returns the current value 2 of the object, defined here.

%obj.val3%

Returns the current value 3 of the object, defined here.

%obj.vnum%
%obj.vnum(<value>)%

The virtual number of the object.
If a subfield is provided, it is the equivalent of
(%obj.vnum% == <value>)

%obj.worn_by%

A variable for the character wearing the object, or an empty return

%obj.weight%
%obj.weight(<value>)%

The weight of the object.
If a value is given, it will be added to the current value.

%obj.<global>%

If the specified field is not a recognized one, the object's script global list is searched for a matching global name. If found, its value will be returned.

Rooms

When using field:

The variable returns:

%room.contents%
%room.contents(<vnum>)%

A variable for the first object in the room.
If a subfield is given, a variable for the first object with this vnum.

%room.weather%

The current weather in this room, or an empty return if inside.
Return values: sunny, cloudy, rainy and lightning.

%room.id%

The unique id of the room.

%room.name%

The name of the room.

%room.<direction>%

with <direction> being either:
north, south, east, west, up or down,
this defaults to the (bits) version below.

%room.<direction>(vnum)%

The room vnum this exit leads to.

%room.<direction>(key)%

The object vnum that is a key to this exit.

%room.<direction>(room)%

A variable for the room this exit leads to.

%room.<direction>(bits)%

The list of flags for the exit in the specified direction;
The result is either:
"NOBITS" = no door,
"DOOR" or "DOOR PICKPROOF" = open door
"DOOR CLOSED" or "DOOR CLOSED PICKPROOF" = closed door
"DOOR CLOSED LOCKED" = locked door
"DOOR CLOSED LOCKED PICKPROOF" = locked, pickproof door

%room.vnum%
%room.vnum(<value>)%

The room's vnum.
If a subfield is provided, it is the equivalent of
(%room.vnum% == <value>)

%room.people%

A variable for the first character in the room, or an empty return.

Text Variable Fields

These fields pertain to any variable that contains a string of text. These are often the variables, such as %speech%, which are provided to a script, but can also be variables that have been created by the script, such as %room.north%

When using field:

The variable returns:

%text.strlen%

The number of characters in the string.

%text.trim%

The string without any leading or trailing whitespace. 
This is used to trim extra spaces from the beginning or end of a string.

%text.car%

The first word of the string. 
For %text%="this is the string"; %text.car% will yield "this".

%text.cdr%

Returns all but the first word of the string, trimmed. 
For %text%="this is the string"; %text.cdr% will yield "is the string".

%text.mudcommand%

Returns the mud command the string is shorthand for. Used to make sure the command you react to is the one you want:
For %text%="o"; %text.mudcommand% will yield "open".

Special Variables

Variable name:

The variable returns:

self / %self%

The mob, item, or room running the script. Normal fields may be used with this.

%time.hour%

Returns in-mud hour of day (0..23).

%time.day%

Returns current in-mud day of the month (1..35).

%time.month%

Returns current in-mud month (1..16).

%time.year%

Returns current in-mud year

%people.<room vnum>%

This variable returns the number of people in the room specified via vnum.
This counts all people - also those invisible or with nohassle on.

%random.<number>%

Returns a number from 1 to <number>.
For example, %random.10% would be a value between 1 and 10.

%random.char%

Returns a UID var of a random char in the current room.
%random.char% will not return a character with nohassle on.

%findmob.<room vnum>(<mob vnum>)%

Returns number of mobs in specified room with the specified vnum.
Thx to Mordecai of 4D for this contribution.

%findobj.<room vnum>(<obj vnum>)%
%findobj.<room vnum>(<obj variable>)%
%findobj.<room vnum>(<name>)%

Returns the number of items in the specified room with the specified characteristics.
Thx to Mordecai of 4D for this contribution.

%entity.global()%

Not yet fully documented.

© 2005 Thomas Arp (Welcor). All rights reserved.