Clue
Communication Summary

Communication is a fundamental part of the game. Without it, the player has absolutely no idea what is going on. Communication is used to let the game communicate status to the user, and also to let players and characters communicate with each other. We'll start with the basics and move up to the bigger picture. This summary focuses mostly on the communicate module.

Elementary Communication

As you have seen in problem set three, Swindle uses the echo command to write something to the screen. This is the basis for the tell command. In the game, when you want to display a message to a specific player, you should always use tell.

Why shouldn't you use echo? Consider the case when you're playing on a network, and there are three players. If the game uses echo, we have four windows in which that output could end up. Which one does it go to? We don't know. So, we use tell where we can direct the message to appropriate player or character.

Making it Interesting

Using the capabilities of tell, the game introduces the message method. This method basically creates a few different communication types seen in the game, such as shouting and emoting. Look at the engine interface for the parameters, and then turn to the communicate module for the types of messages. It is important to note that message simply uses tell to convey the message.

The rather important part of message is that it is still directed to a particular listener. So, you could specialize it to capture a certain event directed to a character and then react to it. For instance, a character can react to a player entering the room, by capturing the enter message.

Placing a Message

The place-message method expands the communication system even further by allowing you to give the same message to every listener in the same room. The place-message interface allows you to exclude one listener, and this is detailed in the engine interface. All that happens is place-message gets a list of listener's in the given room and calls message for each one.

Message Types

Using place-message, the game introduces a myriad of communication methods. These include shout, emote, and say. Note that they simply make it easy to communicate by reducing the amount of information you would need to pass to place-message. They also make code a whole lot more readable. Note how these methods communicate to everyone in the room, so if you wanted to do something different, you'd need to use the message method.

What should you use?

Obviously, if you just want to print a string, without any accompanying information, you should use tell if it's directed to one player. Alternatively, you could use place-message and pass #f as the type. This means that the message is printed without the "You say" or "Barney says" prefixes. If however, you would like to include these information prefixes, you should use the emote, say, and shout methods since they are the most readable.




CS212 Home Page
© 2000 Cornell University Computer Science
Prepared by Brandon Bray