#
# file:: cmd_empty.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")
# Empties out a container object onto the floor
def cmd_empty(args)
case args
when nil, ""
sendto(_("Empty what?"))
when /(.+)/
what = $1
fromobj = nil
objs = find_inv(what)
case objs.size
when 0
sendto(_("Couldn't find %{what}." % {:what => what}))
when 1
fromobj = objs[0]
else
sendto(_("Which one?"))
end
if fromobj
if fromobj.kind_of? Container
if fromobj.contents.size == 0
sendto(_("It is already empty."))
else
if fromobj.liq_amt > 0
liq = get_object(fromobj.contents[0])
if liq
sendto(_("You pour the %{liq} on to the floor." % {:liq => liq.name}))
msg = Msg.new _("^p1 pours %{liq} from ^o1 on to the floor." % {:liq => liq.name})
msg.p1 = name
msg.o1 = fromobj.shortname
sendroom(msg)
fromobj.liq_amt = 0
fromobj.contents.clear
else
sendto(_("It is already empty."))
end
else
room = get_object(location)
fromobj.contents.each do |oid|
o = get_object(oid)
fromobj.delete_contents(oid)
o.location = location
room.add_contents(oid)
end
sendto(_("You empty out your %{what} on to the floor." % {:what => fromobj.name}))
msg = Msg.new _("^p1 empties out ^o1 on to the floor.")
msg.p1 = name
msg.o1 = fromobj.shortname
sendroom(msg)
end
end
else
sendto(_("You can not empty that."))
end
end
else
sendto(_("Empty what?"))
end
end
end