DG Script Variable Commands

Staff Commands for Managing Script Variables

Overview

DG Script variables are used to store persistent data on game entities (players, mobiles, objects, and rooms). These variables can be set by triggers and persist across sessions for players. Staff members have access to commands for viewing, modifying, and deleting these variables for debugging and administrative purposes.

Understanding UIDs

Many commands require a UID (Unique Identifier). You can find an entity's UID by using the stat command on it. The UID is displayed in the output and is used to reference that specific instance of a mob, object, or room.

Viewing Variables & Scripts

Commands for inspecting DG Script triggers and variables on game entities.

Command Usage Description
stat scriptvar stat scriptvar <target> Shows attached triggers, script memory, and all global variables on a mob or player.
LVL_IMMORT act.wizard.c:1398
stat stat <mob|obj|room> Normal stat output includes script/trigger information at the end. Calls the appropriate do_sstat_* function for the entity type.
tstat tstat <vnum> Stats a trigger prototype by its VNUM, showing trigger type, commands, and configuration.
LVL_BUILDER dg_scripts.c:3357
vstat vstat { o | m | r | t | s | z } <vnum> Stats a prototype by VNUM without loading it into the game. Options: object, mobile, room, trigger, shop, zone.
LVL_IMMORT act.wizard.c:1874

Syntax Examples

View variables on a player

stat scriptvar Zephyr -- Shows triggers, script memory, and PC global variables on player Zephyr

View a trigger prototype

tstat 5001 -- Shows the definition of trigger VNUM 5001

View a mobile prototype by VNUM

vstat m 3001 -- Stats mobile VNUM 3001 without loading it

Setting Variables

Commands for creating or modifying DG Script variables.

Command Usage Description
set variable set <player> variable <varname> <value> Sets a DG global variable on a player or mobile. Creates the variable if it doesn't exist, or updates it if it does.
LVL_GRSTAFF dg_scripts.c:2563

Syntax Examples

Set a quest stage variable

set Zephyr variable quest_stage 3 -- Sets the variable "quest_stage" to "3" on player Zephyr

Set a tracking variable

set goblin variable kills_count 15 -- Sets "kills_count" to "15" on the mobile named goblin

Important Notes

  • Variable names are case-sensitive
  • Values are stored as strings (scripts convert as needed)
  • Player variables persist across sessions and reboots
  • Mobile/object variables are lost when the entity is purged or extracted

Deleting Variables

Commands for removing DG Script variables from game entities.

Command Usage Description
vdelete vdelete <varname> <uid> Deletes a specific variable by name from the entity with the given UID.
LVL_BUILDER dg_scripts.c:2460
vdelete all vdelete { * | all } <uid> Deletes ALL variables from the entity with the given UID. Use with caution!
LVL_BUILDER dg_scripts.c:2460

Syntax Examples

Delete a specific variable

vdelete quest_stage 200001 -- Deletes variable "quest_stage" from entity with UID 200001

Delete all variables from an entity

vdelete all 200001 -- Removes ALL variables from entity UID 200001 vdelete * 200001 -- Same as above, using * shorthand

Warning: Destructive Operation

Using vdelete all or vdelete * will permanently remove all variables from the target. For players, this can break quest progress and other scripted content. Always confirm the UID and backup if possible before mass deletion.

Attaching & Detaching Triggers

Commands for dynamically adding or removing triggers from game entities at runtime.

Command Usage Description
attach attach { mob | obj | room } <trig_vnum> <target> [location] Attaches a trigger to an entity. Shortcuts: mtr, otr, wtr. The optional location specifies position in trigger list (-1 = end, 0 = beginning).
LVL_BUILDER dg_scripts.c:1061
detach detach { mob | obj | room } <target> { trig_vnum | all } Removes a trigger (or all triggers) from an entity.
LVL_BUILDER dg_scripts.c:1282

Syntax Examples

Attach a trigger to a mobile

attach mob 5001 goblin -- Attaches trigger 5001 to the mobile named "goblin" attach mob 5001 3005 -- Attaches trigger 5001 to mob VNUM 3005 in the room

Attach a trigger to an object

attach obj 6000 sword -- Attaches trigger 6000 to object named "sword" attach otr 6000 1234 -- Same using shorthand, targeting object VNUM 1234

Attach a trigger to the current room

attach room 7000 here -- Attaches trigger 7000 to the room you're standing in

Detach triggers

detach mob goblin 5001 -- Removes trigger 5001 from the goblin detach room here all -- Removes ALL triggers from the current room detach obj sword all -- Removes all triggers from the sword

Zone Restrictions

You can only attach/detach triggers in zones you have edit permission for. This prevents accidental modification of content in other builders' zones.

Quick Reference

Summary table of all DG Script staff commands.

Command Purpose Level
stat scriptvar <target> View triggers and variables on a mob/player LVL_IMMORT
tstat <vnum> View trigger prototype definition LVL_BUILDER
vstat <type> <vnum> View entity prototype by VNUM LVL_IMMORT
set <char> variable <name> <val> Set a variable on a character LVL_GRSTAFF
vdelete <name> <uid> Delete a specific variable LVL_BUILDER
vdelete all <uid> Delete ALL variables from an entity LVL_BUILDER
attach <type> <trig> <target> Attach a trigger to an entity LVL_BUILDER
detach <type> <target> <trig|all> Remove trigger(s) from an entity LVL_BUILDER

Source Code References

For developers, here are the source file locations for these commands:

Function File Line
do_vstat src/act.wizard.c 1874
do_stat_scriptvar src/act.wizard.c 873
do_sstat_character src/dg_scripts.c 1020
do_sstat_object src/dg_scripts.c 1008
do_sstat_room src/dg_scripts.c 996
do_tstat src/dg_scripts.c 3357
perform_set_dg_var src/dg_scripts.c 2563
do_vdelete src/dg_scripts.c 2460
do_attach src/dg_scripts.c 1061
do_detach src/dg_scripts.c 1282