DG scripts
From Wikipedia, the free encyclopedia
DG scripts is a MUD scripting language that MUD builders can use to quickly add advanced interactive features to a MUD without requiring knowledge of a difficult programming language such as C.
Contents |
[edit] The Death's Gate Language
The DG Scripting language was first developed at the now-defunct Death's Gate MUD, and is now a common addition to CircleMUD and some other codebases. Although it is not included in the stock CircleMUD distribution, projects such as Circle With Goodies (CWG) bundle it with their CircleMUD distributions.
While simple and quick to learn, DG is a complete programming language, and all the normal programming expression conventions such as 'if' and 'while' are available.
DG Scripts is based on the idea of the 'trigger' - a small program (script) which is called (run) as a consequence of a certain action. Triggers are normally attached to a mobile, object, or room. Although this may sound restrictive, in practice this set up is limited only by the imagination, as the results of one trigger will often be used to trigger another.
The player, of course, does not usually see the association between object and trigger, so the effects can seem intelligent or random, adding excitement to the MUD. The association can be further masked by a delay or by assigning a variable which is noticed by another trigger later.
[edit] Trigger Types
There are many trigger types, here are five of the most important.
- Random - this trigger is like a dice that is thrown every few seconds, with a certain percentage change of success.
- Command - This lets you create an ad-hoc or local command, i.e. one that only works in one room.
- Speech - This trigger is called if certain keywords or a key phrase is spoken.
- Act - This trigger runs in response to a certain act.
- Greet - This trigger runs when a player (or mob) enters the room).
[edit] Variables
In DG scripts, percent signs are used to show that a word is a variable (similar to csh), for example: %actor.name%
.
The first half of the variable can refer to an actor (player or mob that trips the trigger), or to a mobile, object or room. The second half refers to a property that player or object has, such as the name, virtual number, strength and so on.
[edit] Commands
A script can use any of the normal game commands. It can also use some special 'wizard-like' commands. In most implementations of DG scripts, these commands are prefixed with m, o or w (for mobile, object or room).
- teleport - move a player, mobile or object to somewhere else.
- echo - allows free-form text to be displayed within the room.
- mat - allows commands to be run in other rooms.
- purge - destroy an object.
- load - bring a new object or mobile into the game.
- force - make a player or mobile to do something.
[edit] An example script
The following is not to be considered gameplay advice or 'how-to-play'. It simply shows a working script for a programming language and has no use to the average player. This is intended as an example for a game designer.
This is an actual script that was used in ActsMUD for a while. In this script, if a particular cupboard becomes empty, then a cook will wash up some cups and put them away in the cupboard.
Although it seems, to the player, that the cook is reacting to events; the cook is actually a puppet of the cupboard which stays in full control. The cupboard checks itself every few seconds to see 'if' there are no cups inside (object 22222 is a cup). If so, then the cupboard creates (loads) some new cups, and forces the cook to pick them up (oforce cook get cup), and put them in the cupboard (oforce cook put cup cupboard). The say and echo commands are just to make it all seem a little more natural.
0) Vnum : 11111
1) Name : Cupboard refill
2) Intended for : Objects
3) Trigger types: Random
4) Numeric Arg : 100
5) Arguments :
6) Commands:
if %self.count(22222)%==0
oforce cook say Raca! There are no cups in the cupboard.
oload obj 22222
oforce cook get cup
oload obj 22222
oforce cook get cup
oload obj 22222
oforce cook get cup
%echo% The cook does some frantic washing up.
oforce cook put cup cupboard
oforce cook put cup cupboard
oforce cook put cup cupboard
oforce cook Say that is better
end
[edit] External links
- DG Scripts pages at The Builder Academy - OasisOLC and Deaths Gate script reference, technical and comprensive treatment of DG scripts
- DG Scripts Reference Documentation for the 'Death’s Gate' MUD scripting language. Based on the original documentation (in wiki format)
- DG Scripts Yahoo Group - A mailing list/discussion forum dedicated to the use and development of the Death Gate (DG) scripting language
- Circle With Goodies A version of CircleMUD with DG Scripts pre-installed