Shamelessly swiped from Stephen A. White's home page! -- Telzey

Practical MPI Examples

Return to the Getting Started Page.

Simple Look-Notify Trap on Your Description

There is a look-notify macro writen by Cymoryl (on Furrymuck) which notifies you when someone looks at you.

Usage: {look-notify:}
MPI version of the @6800 desc-notify feature, using all the same message properties, such as _desc_notify_looker, _desc_notify_looked, _desc_objector, and _desc_objected. If a person has a %n property set, then that will be displayed for %n in messages (use {name:me} instead for displaying a person's full name). Look-notify will also evaluate any lists passed to it for embedded MPI commands.
{look-notify:{list:mydesc}}

This displays the list 'mydesc' to the person looking, and notified you that they looked.

Return to the Getting Started Page or the Example Index.


Sample Description with Morphs and Clothes

@desc me= (Concat to all one line)
{pronouns:{prop:_morphs/{prop:morph}},this}{nl}
{pronouns:{prop:_wardrobe/{prop:clothes}},this}{nl}
{prop:ribbon} {prop:extra}
{if:{smatch:{prop:buttons},y*},{nl}{rand:buttons}}
{null:{tell:{name:me} is looking at you.,this}}
This shows a description composed of several parts:

Return to the Getting Started Page or the Example Index.


Locking an Exit to Allow Only a Maximum Number of People into the Room

Locks to properties will run the string value of the property it tries to check, through the MPI parser, before it checks the returned value against the expected value. This means that you can make MPI scripts for locks. Example:

@link west= @lock west=_MyMPIScript:1
@set west=_MyMPIScript:{lt:{count:{contents:{links:this},Player}},10}
This only permits a player to use the 'west' exit if there are less then 10 people in the room to the west.

Return to the Getting Started Page or the Example Index.


Zombies

Making a zombie (puppet) controlling-action (assuming you have a zombie named Sidekick, whose number is #9999):
@action zom=me
@lock zom=me&!me
@set zom=h
@fail zom={null:{force:#9999,{&arg}}}

Return to the Getting Started Page or the Example Index.


Preventing Embarrassing Absent-Mindedness

Making sure you're dressed when you wake up (assuming your @desc is set so that you appear naked whenever you do '@set me=nude?:yes'): This will reset when you connect to the MUCK.
@set me=_connect/always-dressed:&{null:{store:no,nude?,me}}
Making sure you don't wander around sexually aroused (assuming your @desc is set so that you appear aroused whenever you do '@set me=aroused?:yes'): This will reset when you leave the current room for any reason.
@set me=_depart/back-to-normal:&{null:{store:no,aroused?,me}}

Return to the Getting Started Page or the Example Index.


Neat Random Messages

Making a room have neat random messages appear (assuming you've used 'lsedit here=distractions' to make a list of messages):
@set here=_arrive/distractions:&{if:{eq:1,{dice:4}},{null:{delay:{dice:6,10}, {lit:{null:{otell:here,{rand:distractions},#-1}}}}}}
A quarter of the time (i.e. {if:{eq:1,{dice:4}},XXX}) when someone enters the room, display a message from the list 'distractions' after a 6-10 second delay, to everyone. (otell: all but #-1, which means everybody).

Return to the Getting Started Page or the Example Index.


Making a Really Complex Lock

@lock north=female:yes
@set north=female:{if:{lcommon:{prop:sex,me},female{nl}mare{nl}bitch{nl} vixen{nl}doe{nl}vampyress{nl}skunkette{nl}lioness{nl}tigress},yes,no}
Notice that instead of lots of {or}'s and {eq}'s, you can check whether a value equals one of a list of values using {lcommon}.

Return to the Getting Started Page or the Example Index.


Obvious Exits MPI Script

This code will append a list of visible exits to the description of the room. Thanks goes to Nightwind. To use this in reality, one should turn it into a macro, and put the macro into the succ instead, since it saves repetition of code.

This is the ugly, all in one line version, that you would enter in reality:

@succ here={with:estart,{prop:_exitlist_start,this},{if:{&estart},
{&estart},[ Obvious exits: }}{subst:{lsort:{parse:temp2,{filter:
temp,{exits:here},{with:isvis,{tolower:{midstr:{prop:_visible?,
{&temp}},1}},{or:{eq:{&isvis},y},{and:{istype:{links:{&temp}}
{prop:_exit_name,{&temp2}},{name:{&temp2}}}}},\r, }{with:
eend,{prop:_exitlist_end,this},{if:{&eend},{&eend}, ]}}
this is the program expanded out and explained:
@succ here=
The succ of a room will be displayed after the descriptions is
{with:estart,{prop:_exitlist_start,this},
      {if:{&estart},{&estart},[ Obvious exits: }
}
This displays '[ Obvious exits: ' unless _existlist_start is defined. If it is, is is displayed instead.
{subst:
  {lsort:
    {parse:temp2,
Parse takes a list and applies an operation to it, converting it into a new item. In this case, taking all exists that should be shown, and returning a list of the names that should be displayed. This list is sorted and the subst concatenates the list into one line of entries to be displayed. (See further on)
      {filter:temp,{exits:here},
	{with:isvis,
	      {tolower:{midstr:{prop:_visible?,{&temp}},1}},
	      {or:{eq:{&isvis},y},
		  {and:{istype:{links:{&temp}},Room},
		       {ne:{&isvis},n}
		  }
	      }
	}
      },
This generates a list of exits, {exits:here} and filters them, only including the ones that have the prop _visible? set to 'y', or else exits that point to rooms and that don't have _visible? set to 'n'. The result is handed to parse which executes the next section on each entry:
      {if:{prop:_exit_name,{&temp2}},
	  {prop:_exit_name,{&temp2}},
	  {name:{&temp2}}
       }
For every exit returned by the above (by dbref), it return its name, unless the prop _exit_name is defined. If so, it returns that as a name instead.
    }
  }
,\r,  }
This is the end of the parse, lsort and subst, respectively

The list that is generated by parse is sorted (by lsort) and then the subst converts all the '\r' to ' '(2 spaces). This results in the lists of exits being converted from a list of entries, one per line, to a concatenated list, all in one line.

{with:eend,{prop:_exitlist_end,this},{if:{&eend},{&eend}, ]}}
This displays ' ]' unless _existlist_end is defined. If it is, is is displayed instead.

The result of all this is that we have displayed for example:

[ Obvious Exits: East North South West ]