Valarin
Builder's Tutorial: Writing Scripts

9. Writing Scripts

This section is intended to be a brief introduction to triggers and scripting. For more detailed information you should consult the DGScripts Reference.
9 . A

Trigger Commands

All of these commands may not be available depending on the level of the builder.
tedit <trigger vnum>
Bring up the tedit screen for the trigger that you've specified by its vnum.
tedit list
List all the triggers in the zone you are currently building.
tedit list <zone num>
List all the triggers in the given zone.
tedit list <start vnum> <end vnum>
List all the triggers between the start and end vnums given.
tstat <vnum>
Shows all the relevant information of the trigger given, including the script that is run by the trigger.
9 . B

Sample Tedit Screen

Trigger Editor [1601]

1) Name         : Durin's Throne Room
2) Intended for : Rooms
3) Trigger types: Speech 
4) Numberic Arg : 1
5) Arguments    : must
6) Commands:
wechoaround %actor% As %actor.name% finishes speaking the torches suddenly Flare up.
wsend %actor% as you finish speaking the torches suddenly Flare up.
wait 10
wecho the torches return to normal.
9 . C

Introduction to Scripts

Scripts add life to the MUD, they allow you to define special events that happen when the player does something, or which happen completely at random. The DG scripts reference gives a good intoduction to creating scripts so that won't be covered here. It is suggested that you read the DG scripts reference over before continuing on in this document.

tedit is the command to edit and view scripts.

The name of the script is the way you identify the script in the tedit list display, it has no bearing on how the script works, but is useful if you need to find a particular script later from a mass of them.

The intended for option lets you set if this script is designed for rooms, objects or mobs. Your choices are:

0: Mobiles, 1: Objects, 2: Rooms

The trigger types option lets you choose what trigger will cause this script to be executed. Your choices are:

For Mobiles:
 1) Global                 2) Random                
 3) Command                4) Speech                
 5) Act                    6) Death                 
 7) Greet                  8) Greet-All             
 9) Entry                 10) Receive               
11) Fight                 12) HitPrcnt              
13) Bribe                 14) Load                  
15) Memory                

For objects:
 1) Global                 2) Random                
 3) Command                4) UNUSED                
 5) UNUSED                 6) Timer                 
 7) Get                    8) Drop                  
 9) Give                  10) Wear                  
11) UNUSED                12) Remove                
13) UNUSED                14) Load                  
15) UNUSED  

And For Rooms:
 1) Global                 2) Random                
 3) Command                4) Speech                
 5) UNUSED                 6) Zone Reset            
 7) Enter                  8) Drop                  
 9) UNUSED                10) UNUSED                
11) UNUSED                12) UNUSED                
13) UNUSED                14) UNUSED                
15) UNUSED 

The numeric argument's purpose differs with respect to the different triggers that can be used. All the information pertaining to the numeric arguments can be found in the DGscripts reference pages (the triggers page).

The arguments, like the numeric argument, differ according to what trigger is being used. See the DGscripts reference for the appropriate use of arguments.

The commands section contains the script itself. The script is entered using the standard text editor. It is recommended that you have the script written down on paper before starting so that you don't make a hard to fix mistake while using the text editor.

9 . D

Attaching Scripts

I'll use this section to briefly discuss how to attach your created scripts to a room, mob, objects, etc.

Scripts are attached to rooms, objects and mobs, by using the Script option in redit, oedit and medit. The script menu looks as follows:

     Script Editor

     Trigger List:
      1) [1601] Durin's Throne Room

 N)  New trigger for this script
 D)  Delete a trigger in this script
 X)  Exit Script Editor
To add a trigger (and the associated script) to the room, object or mob, just type in N. give the position you want the trigger in and the virtual number of the script. Giving the trigger the position of a trigger already in the list bumps the current trigger and all the triggers underneath it down one to make room for the new trigger. Position of triggers IS important, if there is a situation where two triggers could be activated, only the first one in the trigger list will be performed.

Triggers and their scripts can also be attached temporarily using the attach command but I wont go into detail about that. Use help attach if you'd like to find out more about this command.

And that ends off the tutorial. Hopefully now you will be able to build like a pro. Again, if anything didn't make sense or was covered too briefly, let me know at brokken@subdimension.com.
Previous Chapter | Table of Contents
Builder's Information | Home