Python Scripting usage for MudMagic

I     Python Definition
III   MudMagic python callbacks
II    Python Examples

I. Python
-----------------------
When you create a Trigger or Alias, you are prompted to select either 'Use python script file' or 'Use MudMagic 
Scripting'. If you select to use Python script file, this help file is where you want to be. 

The MudMagic Python script engine is nothing more than a gateway to your local Python install. On Linux, this is the 
path to your Python script. For Window users, a simple python engine is provided with the MudMagic distribution.

II. MudMagic python callbacks
-----------------------
There are certain commands that are looked for by the MudMagic client when dealing with a python script.

	1. Commands to use in your python script to talk to mudmagic client:
	--------------------------------------------------------------------
		send()   sends data back to the client
		messagebox()  creates a popup message box

	
	2. External variables:
	--------------------
Variables can be passed directly from MudMagic client to your Python script by using regular expression. For example, 
to catch the 2 arguments of:  say one two  , you would use a regular expression:  ^say (.*) (.*) . The MudMagic client 
then sends these variables to your Python script in the form: _1 _2 . Please review the script below for further 
examples.


III. Python Examples
-----------------------

Example provided by Davion:

Alias:  ^c (.*) (.*)

#!/usr/bin/python
#Grab the arguments!
attempt = _1
target = _2

#Build us some spells!
spellList = ("fs", "firestorm"),
("fb", "fireball"),
("sc", "sex change")

#A simple function to cycle the spellList
def getSpell(sn):
        for x,y in spellList:
                if sn == x:
                        return y
        return None

#Grab the spell to cast
spell = getSpell(attempt)

#Lets see if it was found!
if spell:
        send("cast '"+spell+"' "+target)
else:
        messagebox("You don't know the "+attempt+" spell!")
