Open new window
Last update:

OasisOLC and Deaths Gate script reference

Script commands

Script commands are commands that have script related interaction. They make up the limited programming language that is part of DG Scripts. More commands for scripts are found on the Game Commands page.

* (comment) nop attach
global context eval
set unset detach
extract if halt
makeuid rdelete remote
return switch case
break done while

* (comment)

* This is an example of a comment
* because of the *'s the lines aren't parsed,
* so the script still works even if it has a lot of
* explanations built in.
%echo% Trigger firing
* The above line sends the text 'Trigger firing' to the room.

Comments are useful in scripts to document what is happening, for future reference, and for others to see what the script does.

Back to table.


Usage: nop
* this line will award the 'actor' with a little gold:

Almost a no-operation. Certain variable/subfield combinations for characters change some attribute about the character. nop allows those changes to be used legally on lines that do not need to process the result.

Back to table.


Usage: attach vnum id
* This small trigger will attach a trigger to the carrier
* this can for instance be used if you want the mob to change attitude
* by adding another trigger (ie - mob was mad - mob got apple - 
* mob gets a 'nicer' trigger attached
attach 3001 

This command allows a script to attach a trigger (referenced by vnum) to anything capable of receiving triggers, by id number. (,, and are examples of id numbers, for use with this command.)

Back to table.


Usage: global variablename
* To make a variable 'reachable' from other scripts
* it has to be made 'global'. In this case I make a local known var %has_bribed_guard%
* and make it global. It's a good idea to use this in conjunction with context.
global has_bribed_guard

Used to change a variable from local to global. If a global variable is modified, this command must be used to update the global contents as well.

Back to table.


Usage: context number
* This little script will make sure one %has_said_hello% exist for each player
set has_said_hello 1
global has_said_hello
* now only scripts running with context = can access this particular variable.
* however - it's a better idea to use vars set on players - see 'remote'

Changes the "context" of a script to this value. When first run, a script's context is 0. When a variable is made global, it is given the current context. When a variable is accessed, if it must be searched for globally, a "found" variable must either have context 0 or the current context. The net result of this is you may have many global variables in a single script, with the same name, differing only by context. Players may have variables; this mostly removes the need for variable context. Previously, a player's ID could be used as variable context to allow a script to service multiple players at once.

Back to table.


Usage: eval variable expression
* this example immidiately evaluates the expression below and stores the result in %result%:
eval result %self.hitp% * 100 / %self.maxhitp% 
say My hitpoint percentage is %result%
* this result will not change after the evaluation even if %self.hitp% changes

The eval command is used to set (or create) the specified variable equal to the result of the immediate evaluation of the provided expression. There also exists a "set" command, with the same syntax. Set differs in that the expression is not evaluated until the variable is accessed.

Back to table.


Usage: set variable expression
* this example sets the value of result to '%self.hitp% * 100 / %self.maxhitp%'
set result %self.hitp% * 100 / %self.maxhitp% 
* The %result% var now works as a 'function' every time it's accessed.
say My hitpoint percentage is %result%
%damage% %self% 30
say My hitpoint percentage is %result%

The set command is used to set (or create) the specified variable equal to the  provided expression, which will be evaluated when the variable is accessed. There also exists an "eval" command, with the same syntax. Eval differs in that the expression is evaluated immediately.

Back to table.


Usage: unset variable
* in this example we have a var %testvar% we no longer need:
set testvar hops happily along
%echo% %testvar%
unset testvar
* please note - if we had made the var global, it'd be gone instead.

Remove the variable from the global variables of this script, or if not found there, from the script.

Back to table.


Usage: detach vnum id
* if we - as described in the attach example, want our mob/obj/room to behave
* differently, it's not always enough to just add another trigger with attach.
* it might be necessary to remove some old ones :
detach 3000

The opposite of attach, this removes a trigger from the specified target.

Back to table.


Usage: extract to-variable word-number from-text
* could be used to do strange things to what people say:
extract testvar1 1 %speech%
extract testvar2 2 %speech%
extract testvar3 3 %speech%
extract testvar4 4 %speech%
say do you mean %testvar4% %testvar3% %testvar2% %testvar1% ?

Place a specific word from the 'from-text' into a new or existing variable 'to-variable'. Do not enclose the name of the to-variable in %'s.

Back to table.


Usage: if (expression)
 elseif (expression)
   if (%arg% == statue) 
   wsend Stealing from the Temple of Nefheistos is certain death!
   wsend  You don't see a %arg% here.

An 'if' must occur before the other three. If expression evaluates to true (see the Expressions page for more detail on expression evaluation), the statements between the if statement and the next elseif, else, or end are executed. If it stopped at an elseif or else, it scans for the next end, and continues execution at that point. If the expression evaluated to false, it searches for the next elseif, else, or end. If it finds an elseif, it checks that expression. If it is true, it executes the statements between the elseif and the next elseif, else, or end, and then finds the end of the block. If it is false, it continues searching in the same pattern, until a true elseif is found, an else is found, or an end is found. There may be 0 or 1 else statements and 0 or many elseif statements in the block.

Back to table.


Usage: halt
* This script attacks players of level 20 and above.
* the reason for the use of halt and return 0 is to make sure
* other scripts are checked too.
if %actor.level%<20
  return 0
  %echo% yells a Battlecry and throws himself at you.
  mkill %actor%

Terminate the trigger execution.

Back to table.


Usage: makeuid variable id
* We have one mob giving a quest. This mob sets the targets id as a
* global on the player via the 'remote' command, like this:
eval quest_object
remote quest_object
* We then have another mob receiving the quest object, with the following script.
if !(%actor.varexists(quest_object)%)
  return 0
* now we know the player has a quest_object variable
makeuid obj %actor.quest_object%
say Have you brought me %obj.shortdesc%, ?
say You must bring it to me to complete your quest, you know.

Create a new variable with the name given, whose contents shall be suitable for referring to a character, object, or room whose id is provided.

Back to table.


Usage: rdelete variable id
* In the above example, when the quest is fulfilled, we
* need to remove the quest_object variable. this is done like this:
say Thank you, - your quest is completed.
rdelete quest_object

Delete a remote variable from the script referred to by the id of its owner.

Back to table.


Usage: remote variable id
* Heavily used for questsvars, a global variable can be remoted to
* players as well as mobs. Like in this example (from a bribe trigger):
if !(%actor.varexists(has_insulted_guard)%)
  eval bribe_gold 12000
  eval bribe_gold 120000

if %amount% < %bribe_gold%
    if %actor.varexists(has_insulted_guard)%
      say You just don't get it, do you ?
      mkill %actor%
      rdelete has_insulted_guard
    set has_insulted_guard 1
    remote has_insulted_guard
    say I'm not THAT cheap! GET OUT, and I'll pretend I never saw you.
    set has_bribed_guard 1
    remote has_bribed_guard
    say Fine, get on with it. But I never saw you, ok ?

Create a global variable belonging to a character or player whose id is specified. The variable must first exist in the script that is running.

Back to table.


Usage: return value
   if (%cmd%==w || %cmd%==west)
     if (%actor.race%==dwarf)
       %send% %actor% The door vanishes as if it was never there, and you step through.
       %echoaround% %actor% As steps through the doorway, the door disappears.
       %teleport% %actor% 4010
       %echoaround% %actor% has arrived.
       %force% %actor% look
       * the trigger returns 1 because the actor is allowed to pass.
       return 1
       * the trigger returns 0 so next trigger is checked.
       return 0

Designate the return value for the script, to be set when the script executes halt, wait, or when it runs out of commands.

Back to table.


Usage: switch expression
   eval line %random.4%
   switch %line%
     case 1
       emote sings a merry song about someone named Fulbert and Beatrice.
     case 2
       emote booms out loudly, 'Heigh Ho! Heigh Ho! It's home from work we go!'
     case 3
       emote tries to sing falsetto, but his voice doesn't agree.

Switch evaluates an expression and looks for a match amongst the case statements that follow. If none of the following case statements are a match, and a default statement exists, the default statement is considered a match. If a match is found, the commands that follow it, up until a done command, are executed.

Back to table.


Usage: case condition
See switch, above

Used to begin a new conditional group in a switch block. See switch, above.

Back to table.


Usage: break
See switch, above

Used to terminate commands in a switch/case block. See switch, above.

Back to table.


Usage: default
See switch, above

Used like "case", but matches any condition not otherwise met.

Back to table.


Usage: while expression
  * a small script to make a bomb go off three seconds after it's dropped.
   set room_var
   * Send a message when the bomb goes off.
   wait 3 s
   %echo% The Grenade blasts into smithereens, striking everyone here.
   * Target the first char
   set target_char %room_var.people%
   * Do stuff
   while %target_char%
   * Set the next target before this one perhaps dies.
     set tmp_target %target_char.next_in_room%
   * This is where the good/bad things are supposed to happen.
     %send% %target_char% The explosion hurts you.
     %damage% %target_char% 30
   * Find next target
     set target_char %tmp_target%
   * Loop back

The while command starts a loop, running until the expression becomes zero or negative. This can make permanent loops - be careful. The switch block must be terminated by a done.

Back to table.


Usage: done
See both switch and while, above.

Used to terminate a while or switch block.

Back to table.


Usage: wait <time> [s]
       wait until <mudtime>
* This script gives the actor 10 seconds to get out.
wait 10 s
mkill %actor%

The wait statement is used to 'pause' the script execution for a period of time. When a script is being executed it will attempt to execute all commands right away. To get small breaks in, and perhaps give the players time to adjust, use the wait command.
If you want to syncronise your script, you can use the 'wait until' feature. It's used like this:

* This script wakes the mob at dawn, and puts him to sleep at night.
wait until 8:00
wait 10
wait 10
wait 10 s
emote looks sleepy.
wait until 21:00
wait 10 s
wait 10 s
Back to table.
© 2005 Thomas Arp (Welcor). All rights reserved.