Fixed bug in destroy command; cleaned up @dig a bit.

This commit is contained in:
Griatch 2009-10-22 14:30:57 +00:00
parent 9b6bd7125f
commit 557c4eb07b
3 changed files with 35 additions and 28 deletions

View file

@ -1010,6 +1010,8 @@ def cmd_dig(command):
except ValueError: except ValueError:
exit_names[ie] = exi.strip() exit_names[ie] = exi.strip()
#source_object.emit_to("dig args: %s %s" % (room_name, exit_names))
#start creating things. #start creating things.
if not room_name: if not room_name:
source_object.emit_to("You must supply a new room name.") source_object.emit_to("You must supply a new room name.")
@ -1031,10 +1033,10 @@ def cmd_dig(command):
if exit_names[0] != None: if exit_names[0] != None:
#create exits to the new room #create exits to the new room
destination = new_room destination = new_room
location = source_object.get_location()
if destination and not destination.is_exit(): if destination and not destination.is_exit():
#create an exit from this room #create an exit from this room to the new one
location = source_object.get_location()
new_object = Object.objects.create_object(exit_names[0], new_object = Object.objects.create_object(exit_names[0],
defines_global.OTYPE_EXIT, defines_global.OTYPE_EXIT,
location, location,
@ -1042,23 +1044,27 @@ def cmd_dig(command):
destination, destination,
script_parent=exit_parents[0]) script_parent=exit_parents[0])
ptext = "" ptext = ""
if exit_parents[0]: if exit_parents[0] != None:
script_parent = exit_parents[0] script_parent = exit_parents[0]
if new_object.get_script_parent() == script_parent: if new_object.get_script_parent() == script_parent:
ptext += " of type %s" % script_parent ptext += " of type %s" % script_parent
else: else:
ptext += " of default type (parent '%s' failed!)" % script_parent ptext += " of default type (parent '%s' failed!)" % script_parent
source_object.emit_to("Created exit%s from %s to %s named '%s'." % (ptext,location,destination,new_object)) source_object.emit_to("Created exit%s from %s to %s named '%s'." % \
if len(exit_names) > 1 and exit_names[1] != None: (ptext,location,destination,new_object))
#create exit back from new room to this one. if len(exit_names) > 1 and exit_names[1] != None:
#create exit back from new room to this one.
destination = source_object.get_location()
location = new_room
if destination and not destination.is_exit():
new_object = Object.objects.create_object(exit_names[1], new_object = Object.objects.create_object(exit_names[1],
defines_global.OTYPE_EXIT, defines_global.OTYPE_EXIT,
destination,
source_object,
location, location,
source_object,
destination,
script_parent=exit_parents[1]) script_parent=exit_parents[1])
ptext = "" ptext = ""
if exit_parents[1]: if exit_parents[1] != None:
script_parent = exit_parents[1] script_parent = exit_parents[1]
if new_object.get_script_parent() == script_parent: if new_object.get_script_parent() == script_parent:
ptext += " of type %s" % script_parent ptext += " of type %s" % script_parent
@ -1067,8 +1073,8 @@ def cmd_dig(command):
source_object.emit_to("Created exit%s back from %s to %s named '%s'." % \ source_object.emit_to("Created exit%s back from %s to %s named '%s'." % \
(ptext, destination, location, new_object)) (ptext, destination, location, new_object))
if 'teleport' in switches: if new_room and 'teleport' in switches:
source_object.move_to(new_room) source_object.move_to(new_room)
GLOBAL_CMD_TABLE.add_command("@dig", cmd_dig, GLOBAL_CMD_TABLE.add_command("@dig", cmd_dig,
priv_tuple=("objects.dig",), help_category="Building") priv_tuple=("objects.dig",), help_category="Building")
@ -1333,20 +1339,21 @@ def cmd_lock(command):
function() is called on the locked object (if it exists) and function() is called on the locked object (if it exists) and
if its return value matches the Key is passed. If no if its return value matches the Key is passed. If no
return_value is given, matches against True. return_value is given, matches against True.
- an Attribute:return_value pair (ex: key:yellow_key). The - an Attribute:return_value pair (ex: key:yellow_key). The
Attribute is the name of an attribute defined on the locked Attribute is the name of an attribute defined on the locked
object. If this attribute has a value matching return_value, object. If this attribute has a value matching return_value,
the lock is passed. If no return_value is given, both the lock is passed. If no return_value is given, both
attributes and flags will be searched, requiring a True attributes and flags will be searched, requiring a True
value. value.
If no keys at all are given, the object is locked for everyone. If no keys at all are given, the object is locked for everyone.
When the lock blocks a user, you may customize which error is given by When the lock blocks a user, you may customize which error is given by
storing error messages in an attribute. For DefaultLocks, UseLocks and storing error messages in an attribute. For DefaultLocks, UseLocks and
EnterLocks, these attributes are called lock_msg, use_lock_msg and EnterLocks, these attributes are called lock_msg, use_lock_msg and
enter_lock_msg respectively. enter_lock_msg respectively.
<<TOPIC:lock types>>
[[lock_types]]
Lock types: Lock types:
Name: Affects: Effect: Name: Affects: Effect:

View file

@ -569,12 +569,12 @@ class Object(models.Model):
for obj in objs: for obj in objs:
home = obj.get_home() home = obj.get_home()
text = "object" text = "object"
if obj.is_player(): if obj.is_player():
text = "player" text = "player"
# Obviously, we can't send it back to here. # Obviously, we can't send it back to here.
if home.id == self.id: if home and home.id == self.id:
obj.home = default_home obj.home = default_home
obj.save() obj.save()
home = default_home home = default_home

View file

@ -150,14 +150,14 @@ class EvenniaBasicObject(object):
description = target_obj.get_attribute_value('desc') description = target_obj.get_attribute_value('desc')
if description is not None: if description is not None:
retval = "%s\r\n%s%s" % ( retval = "%s%s\r\n%s%s%s" % ("%ch%cc",
target_obj.get_name(show_dbref=show_dbrefs), target_obj.get_name(show_dbref=show_dbrefs),
target_obj.get_attribute_value('desc'), lock_msg target_obj.get_attribute_value('desc'), lock_msg,
) "%cn")
else: else:
retval = "%s" % ( retval = "%s%s%s" % ("%ch%cc",
target_obj.get_name(show_dbref=show_dbrefs), target_obj.get_name(show_dbref=show_dbrefs),
) "%cn")
# Storage for the different object types. # Storage for the different object types.
con_players = [] con_players = []