A Command to Change One Property

If you don' t know how to include changeable properties in your character's description go read how before you start this 'lesson'.

Okay, so you have a property in your character description but you're getting really tired of having to copy and paste or type out @set me=property:description over and over and over again. Here's where we get the MUCK to do the property setting for us.

Let's start by assuming you have a description something like this:

He's lean and wiry, a tall elegant feline with warm brown eyes and a lopsided smile. Thick sable hair pours down over his shoulders to the middle of this back, the glossy strands shining nearly as bright as the numerous silver rings in his left ear. {prop:garb}

And you have been changing your clothing description by hand and you have more than just one or two outfits (and a sophisticated cat like that would definitely have more than just jeans and tee shirt and nude). Let's make changing clothing a bit simpler for you.

The first stage is to put your clothing descriptions on our character in properties. Since you're using garb for what you are currently wearing let's put all your outfits in a directory called _garb. The underscore will keep all your outfits from being listed out when you use 'ex me' and help keep things neat and orderly. You store each outfit in a property under _garb and the name of that property will be the name you use with your command to change clothes.

@set me=_garb/jeans:His jeans have seen better days. The hems are ragged, the knees torn out, but they look incredibly comfortable. Likewise, the sweatshirt is a bit battered, dabbed with paint and grease stains. You've obviously caught him between messy projects.

Store your other outfits in the same way, such as _garb/dockers and _garb/tux.

Now we create an action to be out command. Try something like wear and attach it to yourself:

@action wear=me

Now we need to link it to a program called 'do-nothing' that is available and registered on most MUCKs (if you get an error message ask an on-duty help staffer how to link to do-nothing). This is necessary because actions are really exits that don't go anywhere.

@link wear=$nothing

Let's be paranoid and lock the command so only you can use it.

@lock wear=me

Now we can turn this action into a command to change your clothes. When you go through an exit you get moved to where it's linked to and you see the success message. Our command it linked to do-nothing so we go nowhere but we still 'see' the success message. This success message will be what changes the clothing on our character.

This is the simplest way to set the success property on your command, not the best:

@success wear={store:{prop:_garb/{&arg},me},{prop:garb, me}}

First you'll notice the {prop: } primitive has gotten more complex. In your description the me portion is implied, but here we specify that the property is on the character explicitly since the default would have the MUCK look on the command for the property. The first argument in the {prop: , } primitive is the name of the property, the second is the object the property is stored on.

The {&arg} is the argument you typed with your command, wear jeans would make {&arg} equal to jeans.

{store: , } tells the MUCK to put the first argument in the second argument. When you type wear jeans it puts the contents of _garb/jeans into garb.

There are some problems with leaving it like this. What if you typed wear jeand by accident? And what do other people in the room see?

First, let's do the error handling. We'll need to check of the outfit you're requesting exists, that needs an if statement, then we need to have it tell you if it doesn't. [This would be all one line, I've wrapped it artifically.]

@success wear={if:{strlen:{prop:_garb/{&arg},me}},
{store:{prop:_garb/{&arg},me},{prop:garb, me}},
{tell:You don't have that outfit.,me}}

As you can see there are some more primitives here. The simplest is {tell: , } which prints the string in the first argument to the player named in the second argument (the me could be left out since it's implied by default). Note that if you use commas in this string you must escape them with a backslash like this:

{tell:I'm sorry\, you don't have that outfit.}

The {strlen: } primitive returns the number of characters in the string argument. If there is no string in the property asked for it returns zero.

Any non-zero number is interpreted by the {if: , , } primitive as true so the the three arguments for the {if: , , } are the expression (the true/false test), the true case, and the false case.

Okay, so now it tells you if it doesn't work. How about telling you if it does work? For this we're going to group two primitives together in the true case using {null: } which does nothing itself.

@Success wear={if:{strlen:{prop:_garb/{&arg},me}},
{null:{store:{prop:_garb/{&arg},me},{prop:garb, me}},
{tell: You change your clothes.}},
{tell:You don't have that outfit.,me}}

As you can see we've put both the {store: , } and a {tell: } in the {null: } so you'll know that the command worked.

Now you have to decide if you want others to know that your changed your clothing. The easiest answer is 'no' in which case you just do this:

@osuccess wear={null:}

If you want to tell others in the room that you changed your clothing you need to do something like this:

@osuccess wear={null:{if:{strlen:{prop:_garb/{&arg},me}},
{otell:changes his clothes.}}}

The {if: , , } has no false case, just a true. The {null: } suppresses all messages other than the {otell: } so a message is only printed to other people if the change of clothing worked. The {otell: } primitive works like {tell: } but instead of sending the message to you it sends it to everyone in the room except you. Note that {otell: } prepends your name to the beginning of the string, just like an osuccess message on an exit.

That is the basic command to change one property. It can be made more complex to change more than one property at once and to allow you a 'quiet' and 'verbose' command in one action. Those options will be covered on other pages.


Code Main

 

©1997-2001 Lynn A. Davis