START OF DOCUMENT PREVIOUS PAGE
Copyright © 1995 Robert M. Free - publishing rights reserved
MUTT(tm) and MUTTER(tm) are trademarks of Robert M. Free

This document may be freely copied and distributed, provided that: this copyright notice is included, the entire body of text is included, and the textual content of this document is unchanged.

For written permission to use portions of this document in other publications, send email to bfree@graphcomp.com.


[] MUTTER(tm) Script Examples

The best way to learn how to write scripts is to make a copy of the SIMPLE.MUT script and modify it so that it will autologin to your mud.

Once you've done that, you can begin to add script commands/macros and hotkeys. After you're familiar with writing scripts, then you can begin defining triggers. A number of sample scripts are available at http://www.graphcomp.com/mutt/mudlist.html

The following gives some examples on how to do some simple tasks:


"Away From Keyboard" Script

This script defines function key F5 to turn on an "away from keyboard" trigger which tells other players that you are AFK when they try to talk to you.

[Variables]
;this is to save the player name attempting to talk to you while you are away.
who_var     = str, 128


[Scripts]
;this script turns on the AFK trigger
afk_on   = trigger( afk_trg, afk_proc );

;this script tirns off the trigger
afk_off  = trigger( afk_trg, break );

;this processes the trigger and saves the players name in who_var
afk_proc = setword( who_var, TRIGGER_LINE, 1 ); do( afk_say );

;this tells the player that you are away
afk_say  = say( "tell ", who_var, " Sorry, currently afk :(" );


[Triggers]
;this is the AFK trigger string
afk_trg = "tells you", 0


[HotKeys]
;F5 enables AFK trigger
f5      = afk_on

;Shift-F5 disables trigger
s_f5    = afk_off

"You killed..." Script

This script uses a trigger to process a corpse after it's been killed:

[Scripts]
;this enables the "killed_trg" trigger at startup.
init        = trigger( killed_trg, killed );

;this defines the "killed" script which is called when the "killed_trg" is set off.
;it first acquires the last word of the trigger line, filters out punctuation,
;then call the "corpse" script.
killed      = setword( object, TRIGGER_LINE, -1 ); clean( object, "." ); do( corpse );

;this script checks if the object is an orc - if so, it calls "bury", otherwise
;it calls the "animal" script.
corpse      = if( findstr( object, "orc", 0 ) ) do( bury ) else do( animal );

;this scripts checks if the object is an owl - if so, it calls "pluck", otherwise
;it calls "skin".
animal      = if( findstr( object, "owl", 0 ) ) do( pluck ) else do( skin );

;both of these call "fix_meat".
pluck       = say( "pluck ", object ); do( fix_meat );
skin        = say( "skin ", object ); do( fix_meat );

;prepares meat for eating.
fix_meat    = say( "gut ", object ); say( "carve ", object ); say( "eat meat" ); do( bury );

;buries remains - note, this is called by "fix_meat" and "corpse".
bury        = say( "bury corpse\ntake all" );

;this script uses a prompt, rather than a trigger to call corpse.
do_corpse   = prompt( object, object, "handle corpse:" ); do( corpse );


[Triggers]
;this defines the trigger.
killed_trg  = "killed", 0


[HotKeys]
;this defines the F5 function key to run the "do_corpse" script - in case the trigger is off.
f5          = do_corpse

NEXT PAGE Debugging Scripts


For more information on MUTT(tm), email mutt@graphcomp.com.