User:Luke/Code/Basic Attribute Manipulation

From Serenity : The Wiki
< User:Luke
Revision as of 11:10, 15 December 2008 by Luke (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

All commands specified in blockquotes beneath are to be entered literally as they appear.

Setting attributes

&name me=value

Sets the attribute "name" on yourself to "value". Literally. Embedded Mushcode functions will not be evaluated.

@set me=name:value

Sets the attribute "name" on yourself to "value". Embedded Mushcode functions will be evaluated.

Calling functions

@set me=thetime:[time()]
think time()
think [time()]

Try these chunks of code to get a feeling of what mushcode functions do. Now for a little bit of recursion:

@set me=foo:bar
think [get(me/foo)]
@set me=foo:more [get(me/foo)]
ex me/foo
think [get(me/foo)]

Typing the above block into your mushclient should show you how the get() function works; more information is available in help get().

A practical application

@set me=wave:Hello,%r
@set me=wave:[get(me/wave)]I wanted to say Hi.%r
@set me=wave:[get(me/wave)]Greetings,%r
@set me=wave:[get(me/wave)]me.

ex me/wave
think %N
+wave %N=Subject/[get(me/wave)]

Try it. %N typically evaluates to the name of the object that is using the command. This is in this case you. I use this so the wave is sent to yourself and you can see it.