cmd_say.rb

znmud-0.0.1/cmd/zombie/cmd_say.rb · 971 B

From the archive znmud-minimal-0.0.1.tar.gz

Download the archive   « Back to the archive contents

#
# file::    cmd_say.rb

# This source code copyright (C) 2009 Craig Smith
# All rights reserved.
#
# Released under the terms of the TeensyMUD Public License
# See LICENSE file for additional information.
#

module Cmd

  bindtextdomain("cmd")

  # sends <message> to all characters in the room
  def cmd_say(args)
    if has_attribute? :zombie or self.is_a? Zombie and args
	# Urban Deads Zombie Lexicon :D
	args.gsub!(/[cdefijklopqstuvwxy0-9`~\\\/;:\"\'\{\}\[\]\@\#\$\%\^\&\*\(\)\-_+=|]+/i, "")
    end
    case args
    when nil, ""
      sendto _("What are you trying to say?")
    else
      sendto _("You say, \"%{args}\"." % {:args => args})
      get_object(location).characters(id).each do |p|
	msg = Msg.new _("^p1 says, \"%{args}\"." % {:args => args})
	msg.p1 = name
        if has_attribute? :invisible
		msg.p1 = _("someone") if not p.cansee? :invisible
	end
	add_event(id,p.id,:show,msg)
      end
    end
  end

end

Site Stats

Snippets: 1791
Codebases: 571