& TCL & @tcl PennMUSH TCL Enhancements PennMUSH TCL patch by Thorvald Natvig (slicer@bimbo.hive.no) PennMUSH TCL web page is at: http://slicer.hive.no/tcl/ Helpfiles edited by Jonathan Booth (kamikaze@imsa.edu) Last update: March 31, 1999 TCL commands that interface to the MUSH. TinyMUSH compatable commands have a '*' appended: addcmd addfunc addhook ansi attrib connection debug getattrib* html mushfunc* notify object pemit* setattrib* MUSH Functions and Commands defined by PennMUSH TCL: evaltime() tcl() tclclear() tcleval() tclparams() tclregs() @tcl Attributes used by PennMUSH TCL: TCLBOOT Note that in specifying dbrefs, tcl will take either '#1' or '1' to mean what you would express as #1 in MUSH code. For more help, see 'help TCL ' & TCL getattrib getattrib object attribute Return the value of attribute on object. Example: if { [getattrib $player sex] == "Male" } { pemit $player "Wow, you are a male!"; } else { pemit $player "Oops, I guess you aren't a male!"; } & TCL mushfunc mushfunc Returns the evaluation of by the regular MUSH parser. Example: pemit $player "This PennMUSH's name is: [mushfunc mudname()]"; & TCL pemit pemit object message Send message to object. Return nothing. Example: for { set i 1 } { $i <= 10 } { incr i } { pemit $player "Hi this is pass #$i of 10"; } & TCL setattrib setattrib object attr value Set attribute attr on object to to the value of value. Return nothing. Example: setattrib $player sex "Male"; & TCL addcmd addcmd Restricted to Wizards. Adds a command CmdName that calls procedure ProcName. ProcName must not be the same as CmdName, and the procedure ProcName must be in the same interpreter as the call to addcmd. The field allows the command to have some basic info that all hardcoded PennMUSH commands do. For a list of valid falgs, see 'help tcl addcmd flags'. Example: proc cmd_mudname { enactor caller switches argleft } { pemit $enactor "You are the enactor on [mushfunc mudname()]"; pemit $caller "You are the caller of @mudname. You gave the \ following switches: $switches"; if { [string length $argleft] != 0 } { pemit $enactor "You gave '$argleft' as arguments to me."; } } addcmd @mudname cmd_mudname "nogag"; Continued in 'help tcl addcmd2'. & TCL addcmd2 Second example using the EQSPLIT flag: proc cmd_substr { enactor caller switches substr1 substr2 } { pemit $enactor "The first substr is $substr1, the second substr \ is $substr2."; } addcmd @substr cmd_substr "nogag eqsplit" Note that even if you '@substr' this command will still run, just with null arguments for substr1 and substr2 (argleft and argright of the equal sign respectivally). & TCL addcmd flags The valid flags for the field are: NOGAG makes it so gagged players can't use it NOGUEST makes it so guests can't use it WIZARD making it so that only Wizards can use it ADMIN making it so that only Royalty and Wizards can use it GOD making it so that only #1 can use it EQSPLIT splitting the command into 2 different args at the equal sign LNP causes everything on the left side of the equal sign not to be parsed RNP same as lnp except for the right rather than left side LA parse everything on the left side of the equal sign into seperate attribs by seperation by ' ' RA same as la only for the right rather than left side. You can combine two or more of these together, to increase functionality. & TCL addfunc addfunc Restricted to Wizards. Adds a function called FunName to the MUSH similar to '@function'ed function that calls ProcName when invoked. Procedure ProcName must be defined and in the same interpreter as the addfunc call. Min args and Max args are integers representing the minimum and maximum number of arguments the function will accept. The eval type is a indication to the MUSH if the arguments should be parsed or not, and may have the following values: REG Causes the arguments to be parsed NOPARSE Causes the arguemtns not to be parsed Example: proc func_test_args { enactor caller switches arguments } { if { [llength $arguments] > 2 } { pemit $enactor "Wow you entered more than half the possible \ arguments." } } addfunc test_args func_test_args 1 4 reg > think test_args(1, 2, 3) Wow you entered more than half the possible arguments. Note that since functions can't have switches, that field will always be empty. The arguments variable is passed as a TCL list of all the arguments supplied to the calling MUSH function. & TCL addhook addhook Restricted to Wizards. Adds in a 'hook' or call to procedure proc into the specified hook. An important note: the procedure proc must be a procedure defined within the interpreter that calls addhook. This command has the following options for : clone connect create dbdump disconnect free shutdown startup timer Example: proc message {} { pemit 1 "Did you know that at this moment the DB is dumping?!" } addhook dbdump message See 'help TCL addhook