A Guide to MOO VERBosity
This is a beginners guide to MOO verbs. It is intended for those who have managed to work out how to speak, emote, get around and generally have fun, but who are wondering what the hell all these wierd responses and bits of programming are. It is written by someone who has no knowledge of programming or C++; if you do understand this you're probably streets ahead. Reading this will help you understand how to program simple basic verbs - there are manuals out there that you can read if you want to go further and get into more complicated stuff.
As a brief recap: Everything on the MOO is an object. Players, rooms, bots, items, everything. Objects have properties, and this makes them what they are.
You will probably realise by now that when you send a stream of input to the MOO, the database analyses it and handles it according to certain rules:
If the FIRST character in the stream is:
" This is regarded as speech, and is printed 'as is'.
' This is a 'page' message. The MOO will expect to see the name of someone who is currently logged in following the quote. - eg 'Gaseous Hello.
- This is directed speech. The MOO expects to see the name of someone in the same room as you. eg -Gaseous Hello.
@ A command is following. This allows you to perform functions on the MOO database - eg @audit Gaseous
NONE OF THE ABOVE:
This is where verbs happen. The MOO looks at the first word, or combination of words. If that matches a "keyword" that someone has taken the trouble to define previously, then a small bit of programming will be activated. Think of verbs as keywords which trigger little pieces of programming. All the "social" actions are in fact verbs - when you type grin, laugh, cackle, etc, you are activating "verbs".
A verb is NOT an object; rather it is defined on, or added to, an object. This is one reason for the "feature objects" that you can add to your character to give you access to a wider range of nifty actions - they are just convenient "handles" which carry verbs around. Almost any object can have a verb defined on it.
To create a verb: (eg a smack verb on object #999) the command is @verb #999:smack (And if you want to remove it the command is @rmverb #999:smack)
Important Stuff
Verbs have ARGUMENTS and PERMISSIONS. You need to understand these to work with them.
Arguments are three in number, and are (1) Direct Object (2) Preposition and (3) Indirect object.
The DIRECT OBJECT is someone/something directly affected by the action of the verb. A direct object can be "any" "this" or "none". If the initial argument is "none", then the MOO does not require any further input - if you type 'smack' the verb will be activated. An argument of "any" means that input is required; the MOO will scan it to try to match it with a valid object. eg you could type 'smack Mono'. If Monomolecular is present, the conditions are fulfilled, and the verb will run.
The PREPOSITION allows you to say what you are doing. Prepositions can be with, from, to, out of, etc..
The INDIRECT OBJECT must be another object. Again, this can be "any" "none" or "this". "This" refers to the object on which the verb is defined.
As an example, if I defined a verb on a generic weapon (sword) called "attack" and made the arguments "any with this", to activate the verb you would have to type 'attack <someone> with sword'. A simple verb (like 'grin') that only needs one word to activate it will have arguments of none none none.
To change the arguments of a verb just type @args #999:smack any none none (if that's what you want)
Permissions are also three, as follows:
r means that the verb is readable. Useful for looking at it - also I think it won't work very well if it isn't.
d means that it can be debugged. Handy.
x means it can be called from within MOO programs. Verbs are by default rd when you create them - I found it necessary to add x to the verbs on my bots so they could be executed from the behavior script.
The command to change permissions is @chmod #999:smack rxd (or whatever perms you want).
To Program a Verb
Now that you have a keyword defined, you need to program it. To do this, type @edit #999:smack and you will be taken to the verb editor.
There are a few simple rules here: the MOO needs to be told WHO to tell stuff to, and WHAT to tell them. The first part of the line is the former; the stuff inside brackets represents the actual output. Some sample verb code might look like this:
player:tell("You don't know what you're doing!");
player.location:announce(player.name, " looks around wildly.");
Now a few words are in order explaining the structure of the output (the stuff in the brackets).
Rules are as follows: Think of this as a LIST which is made up of ELEMENTS. Separate elements are separated by commas.
"A GROUP OF CHARACTERS AND SPACES" (like this one) can constitute an element.
Anything enclosed in doublequotes will NOT be analysed by the MOO - it figures that this is what you want to say, and it will be printed "as is".
Anything NOT in quotes must mean something, and will be analysed by the MOO as the verb runs - appropriate values will be substituted. For instance for player.name the MOO will insert the name of the player referred to; player.po will call the appropriate pronoun (him, her, it etc), player.pp calls the possessive pronoun (his, her, its etc).
To finish each line a semicolon is required.
Now look at a verb I placed on The Raging Dragon - trigger this by typing rdance <name>
Now editing #359:rdance (any none none).
1: player:tell("You walk over to ", dobj.name,
" take ", dobj.po, " by the hand, and lead
", dobj.po, " onto the dance floor.");
2: dobj:tell(player.name, " walks over to you, takes
you by the hand, and leads you onto the dance floor.");
3: player.location:announce_all_but({player, dobj},
player.name, " walks over to ", dobj.name,
" and leads ", dobj.po, " onto the dance
floor.");
4: suspend(2);
5: player:tell("You nod to the band, and they start
playing a gentle waltz.");
6: player.location:announce(player.name, " nods to
the band, and they start playing a gentle waltz.");
7: suspend(3);
8: player:tell("Taking ", dobj.name, " in
your arms, you gently lead ", dobj.po, " around
the floor.");
9: dobj:tell(player.name, " takes you in ",
player.pp, " arms, and gently leads you around the
floor.");
10: player.location:announce_all_but({player, dobj},
player.name, " takes ", dobj.name, " in
", player.pp, " arms, and leads ", dobj.po,
" around the floor.");
11: suspend(5);
12: player:tell("The world seems to recede as you
and ", dobj.name, " move in perfect harmony.");
13: dobj:tell("The world seems to recede as you and
", player.name, " move in perfect harmony.");
14: player.location:announce_all_but({player, dobj},
player.name, " and ", dobj.name, " make a
lovely couple as they move in perfect harmony.");
15: suspend(7);
16: player:tell("As the music stops, you reluctantly
come to a halt. You hug ", dobj.name, " and
escort ", dobj.po, " back to the seat.");
17: dobj:tell("As the music stops, you reluctantly
come to a halt. ", player.name, " hugs you, and
escorts you back to the seat.");
18: player.location:announce_all_but({player, dobj},
"As the music stops, ", player.name, "
hugs ", dobj.name, " and escorts ", dobj.po,
" back to the seat.");
Pop over and run the verb sometime, and compare the output with the strange-looking code. Another good technique is to look at what other people have done (that's mainly how I learned). If you suspect an object (say #555) has verbs on it, just check by typing @verbs #555. You will get a list of all verbs on that object. If you see a verb, (eg cheat) look at the code by typing @list #555:cheat.
Entering code in the Verb Editor is similar to the note editor, in that you enter "say" to get anything written. So to enter suspend(5); you would type say suspend(5);
When you've entered the code you want, the command is not save; rather it is compile, or com. If the verb is grammatically OK it will be compiled - if not you get a message "verb not compiled due to syntax error in line x". Doesn't tell you what the error is, but at least you know where to look while you're tearing your hair out.....
Also I have two "order" verbs in the Checquered Cork - one on Rutherford and one on Ophelia. The arguments for both are any from this. Look at the codes and you should be able to figure it out.
If you want to get into serious programming, and you have understood this primer, you MIGHT want to look at The Lambda MOO Programmers Manual. Be warned - it's not that easy to understand....
Good luck......