znmud-0.0.1/benchmark/
znmud-0.0.1/cmd/
znmud-0.0.1/cmd/emotes/
znmud-0.0.1/cmd/objects/
znmud-0.0.1/cmd/tiny/
znmud-0.0.1/doc/
znmud-0.0.1/farts/
znmud-0.0.1/lib/
znmud-0.0.1/lib/combat/
znmud-0.0.1/lib/core/bodytypes/
znmud-0.0.1/lib/engine/
znmud-0.0.1/lib/farts/
znmud-0.0.1/logs/
#
# file::    cmd_load.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")

  # Loads an object based on it's oid
  def cmd_load(args)
    case args
    when /#(\d+)/
	curr = get_object(location)
	if not curr.owner == id and not world.is_admin? id
		sendto _("You can not load items into this room.  Permission Denied")
		return
	end
	o = get_object($1.to_i)
	case o
	when nil, 0
		sendto _("No object with that oid found")
	when Mobile
		newmob = world.load_object(o.id)
      		if newmob.nil?
       		 log.error "Unable to create Mobile object."
	         sendto "System error: unable to create Mobile object."
	         return
      		end
		newmob.location = location
		newmob.reset
	        get_object(location).add_contents(newmob.id)
		sendto _("You conjour up %{mob} out of thin air" % {:mob => newmob.name})
		msg = Msg.new _("^p1 conjours ^o1 out of thin air!")
		msg.p1 = name
		msg.o1 = newmob.name
		sendroom(msg)
	when Room, Character, Account, Script, String, Spawn, Liquid
		sendto _("You can not load that type of object")
	else #GameObject
		newobj = world.load_object(o.id)
		newobj.delete_attribute(:buried) if newobj.has_attribute? :buried
      		if newobj.nil?
       		 log.error "Unable to create object."
	         sendto "System error: unable to create object."
	         return
      		end
		newobj.location = location
		newobj.reset if newobj.respond_to? "reset"
	        get_object(location).add_contents(newobj.id)
		sendto _("You create %{obj} out of thin air" % {:obj => newobj.shortname})
		msg = Msg.new _("^p1 creates ^o1 out of thin air!")
		msg.p1 = name
		msg.o1 = newobj.shortname
		sendroom(msg)
	end
    else
        sendto _("@load #<oid>")
    end
  end

end