mirror of
https://github.com/evennia/evennia.git
synced 2026-03-19 14:26:30 +01:00
Moving script_parent to a field on the object model. This is critical enough to warrant it being there instead of in an attribute. Minor changes here and there.
NOTE: This update adds a field, delete your evennia.db3 or manually add a NOT NULL 'script_link' charfield(255).
This commit is contained in:
parent
bd3d195d5b
commit
9a166ba024
5 changed files with 24 additions and 11 deletions
|
|
@ -271,15 +271,17 @@ def cmd_examine(command):
|
|||
along with detailed information about said object.
|
||||
"""
|
||||
# Format the examine header area with general flag/type info.
|
||||
session.msg("%s\r\n%s" % (
|
||||
target_obj.get_name(fullname=True),
|
||||
target_obj.get_description(no_parsing=True),
|
||||
))
|
||||
session.msg(target_obj.get_name(fullname=True))
|
||||
session.msg("Type: %s Flags: %s" % (target_obj.get_type(),
|
||||
target_obj.get_flags()))
|
||||
session.msg("Desc: %s" % target_obj.get_description(no_parsing=True))
|
||||
session.msg("Owner: %s " % (target_obj.get_owner(),))
|
||||
session.msg("Zone: %s" % (target_obj.get_zone(),))
|
||||
|
||||
parent_str = target_obj.script_parent
|
||||
if parent_str and parent_str != '':
|
||||
session.msg("Parent: %s " % (parent_str,))
|
||||
|
||||
for attribute in target_obj.get_all_attributes():
|
||||
session.msg(attribute.get_attrline())
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ def show_cached_scripts(command):
|
|||
for script in cache_dict.keys():
|
||||
retval += "\n " + script
|
||||
retval += "\n" + "-" * 78 + "\n"
|
||||
retval += "%d cached parents." % len(cache_dict)
|
||||
retval += "%d cached parents" % len(cache_dict)
|
||||
session.msg(retval)
|
||||
|
||||
def cmd_parent(command):
|
||||
|
|
@ -43,3 +43,5 @@ def cmd_parent(command):
|
|||
if "clearcache" in command.command_switches:
|
||||
clear_cached_scripts(command)
|
||||
return
|
||||
|
||||
|
||||
|
|
@ -106,6 +106,7 @@ class Object(models.Model):
|
|||
ansi_name = models.CharField(max_length=255)
|
||||
owner = models.ForeignKey('self', related_name="obj_owner", blank=True, null=True)
|
||||
zone = models.ForeignKey('self', related_name="obj_zone", blank=True, null=True)
|
||||
script_parent = models.CharField(max_length=255, blank=True, null=True)
|
||||
home = models.ForeignKey('self', related_name="obj_home", blank=True, null=True)
|
||||
type = models.SmallIntegerField(choices=defines_global.OBJECT_TYPES)
|
||||
# TODO: Move description to an attribute.
|
||||
|
|
@ -653,12 +654,19 @@ class Object(models.Model):
|
|||
Returns an object's script parent.
|
||||
"""
|
||||
if not self.scriptlink_cached:
|
||||
if self.is_player():
|
||||
script_to_load = settings.SCRIPT_DEFAULT_PLAYER
|
||||
script_to_load = None
|
||||
if not self.script_parent or self.script_parent.strip() == '':
|
||||
# No parent value, assume the defaults based on type.
|
||||
if self.is_player():
|
||||
script_to_load = settings.SCRIPT_DEFAULT_PLAYER
|
||||
else:
|
||||
script_to_load = settings.SCRIPT_DEFAULT_OBJECT
|
||||
else:
|
||||
script_to_load = settings.SCRIPT_DEFAULT_OBJECT
|
||||
# A parent has been set, load it from the field's value.
|
||||
script_to_load = self.script_parent
|
||||
# Load the script reference into the object's attribute.
|
||||
self.scriptlink_cached = scripthandler.scriptlink(self,
|
||||
self.get_attribute_value('__parent', script_to_load))
|
||||
script_to_load)
|
||||
|
||||
if self.scriptlink_cached:
|
||||
# If the scriptlink variable can't be populated, this will fail
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
INSERT INTO objects_object VALUES(1,'Wizard','Wizard',1,0,2,1,'',2,'','CONNECTED','2007-04-25');
|
||||
INSERT INTO objects_object VALUES(2,'Limbo','Limbo',1,NULL,NULL,2,'Welcome to your new Evennia-based game. From here you are ready to begin development. If you should need help or would like to participate in community discussions, visit http://evennia.com.',NULL,'','','2007-04-25');
|
||||
INSERT INTO objects_object VALUES(1,'Wizard','Wizard',1,0,'',2,1,'',2,'','CONNECTED','2007-04-25');
|
||||
INSERT INTO objects_object VALUES(2,'Limbo','Limbo',1,NULL,'',NULL,2,'Welcome to your new Evennia-based game. From here you are ready to begin development. If you should need help or would like to participate in community discussions, visit http://evennia.com.',NULL,'','','2007-04-25');
|
||||
INSERT INTO objects_commchannel VALUES(1,'Public','Public',1,'Public Discussion');
|
||||
INSERT INTO objects_commchannel VALUES(2,'Errors','Errors',1,'Error Log');
|
||||
INSERT INTO objects_commchannel VALUES(3,'Info','Info',1,'Info Log');
|
||||
|
|
@ -133,6 +133,7 @@ class SessionProtocol(StatefulTelnetProtocol):
|
|||
result = Object.objects.get(id=self.uid)
|
||||
return result
|
||||
except:
|
||||
logger.log_errmsg("No session match for object: #%s" % self.uid)
|
||||
return None
|
||||
|
||||
def game_connect_screen(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue