Command Tracker
Code that demonstrates how you can use a command lock to intercept $-commands before they are processed and queued. This example records the number of times each $-command is typed, but command locks of this kind can have many other interesting uses.
Compatibility:
PennMUSH.
Instructions
Copy and paste the below code into a compatible MUSH or MUX.
MUSHCode for Command Tracker
@create Command Tracker
@lock Command Tracker==me
@set Command Tracker=!NO_COMMAND
@lock/Command Command Tracker=PROCESSOR/1
@lset Command Tracker/Command=no_inherit
&C.BAR Command Tracker=$+bar *:@pemit %#=You used the bar command.;@include me/totals
&C.FOO Command Tracker=$+foo:@pemit %#=You used the foo command.;@include me/totals
&PROCESSOR Command Tracker=1[attrib_set(%!/COUNT`[first(%u)],inc(default(COUNT`[first(%u)],0)))]
&TOTALS Command Tracker=@pemit %#=Total uses: [iter(lattr(me/COUNT`*),after(%i0,COUNT`):[v(%i0)])]
think Use the commands '+foo' and '+bar <anything>'.
@lock Command Tracker==me
@set Command Tracker=!NO_COMMAND
@lock/Command Command Tracker=PROCESSOR/1
@lset Command Tracker/Command=no_inherit
&C.BAR Command Tracker=$+bar *:@pemit %#=You used the bar command.;@include me/totals
&C.FOO Command Tracker=$+foo:@pemit %#=You used the foo command.;@include me/totals
&PROCESSOR Command Tracker=1[attrib_set(%!/COUNT`[first(%u)],inc(default(COUNT`[first(%u)],0)))]
&TOTALS Command Tracker=@pemit %#=Total uses: [iter(lattr(me/COUNT`*),after(%i0,COUNT`):[v(%i0)])]
think Use the commands '+foo' and '+bar <anything>'.