A Locket for Remembrance

This is a simple MPI project, the difficult part is writing good descriptions of the locket in the closed and open positions. You might want to do those first.

Start by making your locket object. Give it a descriptive name, not just 'locket'.

@create Antique Silver Locket

If you want to make sure it can't be picked up and taken away lock it to yourself:

@lock locket=me

Now to describe the locket.

@desc locket={eval:{list:{prop:status,this}}}

Which list to use for the description is stored in the property status on the locket object (this).

Use lsedit to create the two lists you need, one for open and one for closed.

lsedit locket=open

Type your description, format it as you want it, save, and exit. (Use .h on a line by itself to get help in lsedit.) Do the same to create a description for the closed locket.

Since we want the locket to start out closed we have to set the initial status appropriately:

@set locket=status:closed

Now we need a command to open and close the locket:

@action open locket;close locket=locket

Link the action to do-nothing

@link open locket=$nothing

Now to do the MPI tricks on the action to turn it into a command. First the success message:

@succ open locket={if:{eq:{&cmd},open locket},{exec:open/succ,locket},{exec:close/succ,locket}}

A pretty straight forward bit of code. An if statement consisting of an expression, true case, and false case. The expression {eq:{&cmd},open locket} compares the command you typed {&cmd} to the string open locket, if they are equal it executes the MPI in the property open/succ on the locket object, if not it executes the property close/succ.

Now we set those properties:

@set locket=open/succ:{null:{tell:You opened the locket.},{store:open,status,locket}}

@set locket=close/succ:{null:{tell:You closed the locket.},{Store:closed,status,locket}}

Make the {tell:} as complex as you like, but remember you'll see these messages whenever you open and close the locket so keep them fairly concise. Remember to escape any commas in the {tell:} strings with backslashes. The {store:} puts either open or closed in the property status where it can be used to determine what description we need to see.

Now that we've taken care of what you see when you open and close the locket we need to set the osuccess message so other people see something.

@osucc open locket={null:{if:{eq:{&cmd},open locket},{otell:opens the locket.},{otell:closes the locket.}}}

Like the success message there is a an if statement to check which command (open locket or close locket) was used and the appropriate message is displayed. Again you can make the {otell:} strings as complex as you like but remember they will be seen by everyone every time the locket is opened and closed. The name of the person opening/closing the locket is prepended to the {otell:} string.

And that's it.

Code Main


©1997-2001 Lynn A. Davis