cmd_load.rb
znmud-0.0.1/cmd/zombie/cmd_load.rb · 1.9 KB
From the archive znmud-minimal-0.0.1.tar.gz
Download the archive « Back to the archive contents
#
# 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