AresMUSH
A New Breed of MUSH Server

Emits

Emits are the way the game communicates with the MUSH clients. The Client class has a few different ways to emit messages.

  • emit - A basic emit.
  • emit_ooc - OOC messages show up in light blue.
  • emit_success - Success notices show up in green.
  • emit_failure - Failure/error alerts show up in red.
  • emit_raw - A special emit that will not evaluate linebreaks or ansi codes.

Try It!

Let’s see what those different formats look like. Change the tinker code as shown, save, and run the command again.

def handle
  client.emit_ooc "Hello, #{enactor.name}!"
  client.emit_success "Success!"
  client.emit_failure "Failure!"    
  client.emit "Here's some %xggreen%xn text.%RAnd a separate line."
end

The last emit shows how you can use Formatting Codes in an emit, including ansi and linebreaks.

Tip: It’s highly recommended that you use the standard emit_ooc / emit_success / emit_failure methods in any custom code you write. This provides a consistent look-and-feel for all game commands and enable log editors to easily filter out these messages.

There are also some more advanced ways to emit to people and rooms, which you can learn about in the Emitting tutorial when you’re ready.

This article is part of the Code Quickstart tutorial.