Other Key Verbs

 

Teleporting
Arguments: this none none
This moves a player to another room
player:moveto(<#room>)
For example: player:moveto(#3323);

A modification of this can be used to move objects to other rooms
<#object>:moveto(<#room>)
For example: #1234:moveto(#9876);

Example in the MOO: go to #3290 and type "watch sunset". Watching the sunset moves you to another room. Here is the coding:
#3283:watch this none none
1: player:tell("As Bob watches the sunset memories long forgotten, and feelings buried for some time rush to the surface, he is overcome by these new feelings and you feel yourself dragged along with him on his flight through his subconscious.");
2: player.location:announce(player.name, " chose the wrong scab to pick.");
3: player:moveto(#3323);

Notice the location of the player:tell and player.location:announce. In this case tell and announce take place before the player moves. The player senses a change then the change takes place. Also,because the announcement is made before the move, the players in the original room hear the announcement but the players in the room the character is teleported to do not hear the announcement.


One Object Effecting Another Object
Arguments: varies
This verb allows one object to change a property on another object. For example, subtracting a point from a property of another object :
<#object>.property = <#object>.property -1;
Example: #4502.chat = #4502.chat - 1;

Example in the MOO: Go to room #4250. Then type "talk to monster". Here if you talk to the monster (#4504), then the Elizabeth character (#4502) loses a .chat point from her object property called “chat”.
Verb command: talk monster
Location: room #4250
#4504:talk none (at/to) this
1: "set points of monster chat and if less than 1 move player to another room"
2 : monster_left = this.chat;
3 : if (monster_left <= 0)
4 : player:moveto(#4541);
5 : else
6 : "tell player what happens and subtract a chat point from Elizabeth's chat property"
7: player:tell("You talk to", " ", this.name, ". He grins at you. Sweet Elizabeth begs you to return home.");
8 : player.location:announce(player.name, " talks to ", this.name, ". He grins.");
9 : #4502.chat = #4502.chat - 1;
10: "Add a point to the monster's chat property"
11 : monster_left = monster_left + 1;
12 : this.chat = monster_left;
13: endif

Notice that changing points on another figure can be used like a video game. In this case, the game is to show the battle between Elizabeth and the Monster for Frankenstein's affection. Every time he talks to one, that object gains points and the other one losses points. If one of the .chat properties gets to zero, the player who talks to that object will be teleported to another room. Alternatively, you could make a two drinks--tea and coffee. Every time you sip tea, the number of sips from coffee is reduced....very Alice in Wonderland sort of effect. Finally, you could have one object move another object by using <#object>:moveto(<#room>);


Random Numbers and Lists
Arguments: variable
This example is a prototype for a wandering cloud. The program shows how to make a list of objects and call on a random number from the list. In this case, the cloud will randomly go to one of the listed rooms. The list of rooms is in line 2. The random number between one and forty generator is in line 5. Then in line 6, the room number in the list from line 2 that corresponds with the random number generated in line 5. The cloud hovers in the room for 30-150 seconds in line 7. Finally, in line 11, the cloud moves to the randomly generated destination room.
Verb command: cloud wander
#5193:Wander this none none
1: player:tell("and off it goes");
2: rooms = {#62, #170, #202, #218, #224, #221, #1922, #1791, #1703, #3055, #3067, #2765, #3073, #3079, #651, #3471, #3537, #2687, #2695, #2704, #2871, #2887, #2908, #2911, #2914, #2883, #2974, #2948, #2677, #2865, #3013, #3045, #2798, #3077, #3092, #3108, #580, #218, #221, #224, #490};
3: this.continue_if = 1;
4: while (this.continue_if == 1)
5: list_num = random(40);
6: destination_room = rooms[list_num];
7: suspend(30 * random(5));
8: this.location:announce("the sun shines once again");
9: player:tell(destination_room);
10: move(this, destination_room);
11: this.location:announce("A small materializes over your head, a voice inside you begs you to ask 'why me?'");
12: endwhile

Commands implemented in this verb:

listname = {items in list, seperated by commas};

random(<number range from 1 to listed number>);

suspend(<number of seconds>)


Object that Makes Other Objects of the Same Kind --Cloning

When you type "steal corpse" this corpse object creates a copy of itself in the inventory of the person who picked it up. The object recycles itself after 60 minutes (see line 17).
One example is a corpse when you type steal corpse it replicates itself. See #5002. The other example is a plant. When you type "pluck plant" it replicates itself. See # 1382 in room #1922.
#5002:steal this none none
1: numstr = tostr(this.corpseNo);
2: namestr = "corpse" + numstr;
3: parent = this;
4: object = player:_create(parent);
5: if (typeof(object) == ERR)
6: player:notify(tostr(object));
7: return;
8: endif
9: for f in ($string_utils:char_list(player:build_option("create_flags") || ""))
10: object.(f) = 1;
11: endfor
12: "move() shouldn't, but could bomb. Say if player has a stupid :accept";
13: `move(object, player) ! ANY';
14: $building_utils:set_names(object, namestr);
15: player:tell("You now have a corpse with you, hit i<enter> to make sure he is in you inventory, then take him to the lab");
16: this.corpseNo = this.corpseNo + 1;
17: fork (60 * 60)
18: player:tell("now");
19: endfork


Forked Time Events
This example shows how to create an event that unfolds over time. First create a property on your object called “t” for time. Then set the value of t to zero (@set object:t 0 ). When the verb is activated, time starts ticking in seconds. At various intervals in time (“fork (2) or fork (8)” for example), the programmer announces something to the players in the room. Go to room #4381 and type "push button".
Verb command: push button
Location: room #4381
#4640:push this none none
1: if (this.t == 0)
2: this.t = 1;
3: player:tell("");
4: player.location:announce("");
5: player:tell("You press the button and the scene before you comes to life...");
6: player.location:announce(player.name, "presses the button and the still scene before you comes to life...");
7: fork (2)
8: player:tell("");
9: player.location:announce("");
10: player:tell("A few feet away, a shadow holds small William by the throat in midair.");
11: player.location:announce("A few feet away, a shadow holds small William by the throat in midair.");
12: endfork
13: fork (8)
14: player:tell("");
15: player.location:announce("");
16: player:tell("William threatens the shadow and it rips a locket free from his neck. It then squeezes his throat before throwing his lifeless body into the thick grass.");
17: player.location:announce("William threatens the shadow and it rips a locket free from his neck. It then squeezes his throat before throwing his lifeless body into the thick grass.");
" ***ETC "
18: this.t = 0;
19 : endfork
20 : else
21 : player:tell("Please wait until the scene resets");
22 : endif

Notice that at the end of the verb (line 18) time is reset to zero then the "endfork" command is given. Also notice that this coder has given provides a blank space between each annoncement or player:tell. This is done in lines 3 and 4, then again in lines 8 and 9 and lines 14 and 15. The space prevents his dialogue from running together in the MOO chat screen.