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.

You can also emit to everyone in a room if you have a room object. In commands, we can use the enactor_room helper to get the enactor’s room.

  • enactor_room.emit
  • enactor_room.emit_ooc
  • enactor_room.emit_success
  • enactor_room.emit_failure
  • enactor_room.emit_raw

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!"    
  enactor_room.emit "This gets sent to the entire room."
  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.

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.