diff --git a/game/gamesrc/commands/examples/state_example.py b/game/gamesrc/commands/examples/state_example.py index 256e695571..0ea4d1a3c8 100644 --- a/game/gamesrc/commands/examples/state_example.py +++ b/game/gamesrc/commands/examples/state_example.py @@ -35,7 +35,6 @@ from src.statetable import GLOBAL_STATE_TABLE #the name of our state, to make sure it's the same everywhere STATENAME = 'menu' - # # 'entry' command # diff --git a/game/gamesrc/parents/examples/red_button.py b/game/gamesrc/parents/examples/red_button.py index 14fb786a91..02f2849d3d 100644 --- a/game/gamesrc/parents/examples/red_button.py +++ b/game/gamesrc/parents/examples/red_button.py @@ -68,7 +68,7 @@ class RedButton(BasicObject): #get stored object related to this class obj = self.scripted_obj - obj.set_description("This is your standard big red button.") + obj.set_attribute('desc', "This is your standard big red button.") obj.set_attribute("breakpoint", 10) obj.set_attribute("count", 0) diff --git a/src/commands/general.py b/src/commands/general.py index c122b68552..e507d8f193 100644 --- a/src/commands/general.py +++ b/src/commands/general.py @@ -282,7 +282,7 @@ def cmd_examine(command): s += str(target_obj.get_name(fullname=True)) + newl s += str("Type: %s Flags: %s" % (target_obj.get_type(), target_obj.get_flags())) + newl - s += str("Desc: %s" % target_obj.get_description(no_parsing=True)) + newl + #s += str("Desc: %s" % target_obj.get_attribute_value('desc')) + newl s += str("Owner: %s " % target_obj.get_owner()) + newl s += str("Zone: %s" % target_obj.get_zone()) + newl s += str("Parent: %s " % target_obj.get_script_parent()) + newl diff --git a/src/commands/objmanip.py b/src/commands/objmanip.py index 974b76ec29..b8e8c72247 100644 --- a/src/commands/objmanip.py +++ b/src/commands/objmanip.py @@ -296,7 +296,7 @@ def cmd_create(command): "location": source_object, "owner": source_object} new_object = Object.objects.create_object(odat) - + new_object.set_attribute('desc', 'Nothing special.') if len(eq_args)>1: parent_str = eq_args[1] if parent_str and new_object.set_script_parent(parent_str): @@ -797,12 +797,12 @@ def cmd_description(command): return new_desc = eq_args[1] - if new_desc == '': - source_object.emit_to("%s - DESCRIPTION cleared." % target_obj) - target_obj.set_description(None) + if not new_desc: + source_object.emit_to("%s - description cleared." % target_obj) + target_obj.set_attribute('desc', 'Nothing special.') else: - source_object.emit_to("%s - DESCRIPTION set." % target_obj) - target_obj.set_description(new_desc) + source_object.emit_to("%s - description set." % target_obj) + target_obj.set_attribute('desc', new_desc) GLOBAL_CMD_TABLE.add_command("@describe", cmd_description) def cmd_recover(command): diff --git a/src/initial_setup.py b/src/initial_setup.py index de7b7ee60f..6acd17f7d9 100644 --- a/src/initial_setup.py +++ b/src/initial_setup.py @@ -33,6 +33,7 @@ def create_objects(): # Create the matching PLAYER object in the object DB. god_user_obj = Object(id=1, type=defines_global.OTYPE_PLAYER) god_user_obj.set_name(god_user.username) + god_user_obj.set_attribute('desc', 'You are Player #1.') god_user_obj.scriptlink.at_player_creation() god_user_obj.save() @@ -40,7 +41,7 @@ def create_objects(): limbo_obj = Object(id=2, type=defines_global.OTYPE_ROOM) limbo_obj.set_owner(god_user_obj) limbo_obj.set_name('%ch%ccLimbo%cn') - limbo_obj.set_description("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.") + limbo_obj.set_attribute('desc',"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.") limbo_obj.scriptlink.at_object_creation() limbo_obj.save() diff --git a/src/objects/models.py b/src/objects/models.py index c88c11f683..ebccb80412 100755 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -113,8 +113,10 @@ class Object(models.Model): 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. - description = models.TextField(blank=True, null=True) + #description = models.TextField(blank=True, null=True) + location = models.ForeignKey('self', related_name="obj_location", blank=True, null=True) flags = models.TextField(blank=True, null=True) nosave_flags = models.TextField(blank=True, null=True) @@ -128,7 +130,6 @@ class Object(models.Model): #state system can set a particular command table to be used. state = None - def __cmp__(self, other): """ Used to figure out if one object is the same as another. @@ -409,39 +410,34 @@ class Object(models.Model): return "%s%s" % (parse_ansi(name_string.split(';')[0], strip_ansi=no_ansi), dbref_string) - def set_description(self, new_desc): - """ - Set an objects description - """ - if new_desc == '': - self.description = None - else: - self.description = new_desc - self.save() +## def set_description(self, new_desc=''): +## """ +## Set an objects description +## """ +## if not new_desc: +## self.set_attribute('desc', 'Nothing special') +## #self.description = None +## else: +## self.set_attribute('desc', new_desc) +## #self.description = new_desc +## self.save() - def get_description(self, no_parsing=False, wrap_text=False): - """ - Returns an object's ANSI'd description or None if description is not - set. - """ - try: - # If no description is set, return None - if self.description is None: - return None - # Evaluate ANSI and stuff? - if no_parsing: - retval = self.description - else: - retval = parse_ansi(self.description) - - # Default to a 78 character wrap. - if wrap_text: - return functions_general.word_wrap(retval) - else: - return retval - except: - # No description attribute present, return empty string. - return None +## def get_description(self, no_parsing=False, wrap_text=False): +## """ +## Returns an object's ANSI'd description or None if description is not +## set. +## """ +## desc = self.get_attribute_value('desc') +## if desc: +## if not no_parsing: +## desc = parse_ansi(desc) +## if wrap_text: +## return functions_general.word_wrap(desc) +## else: +## return desc +## else: +## # No description attribute present, return empty string. +## return "" def get_flags(self): """ @@ -580,13 +576,13 @@ class Object(models.Model): attrib_obj = \ Attribute.objects.filter(attr_object=self).filter(attr_name__iexact=attribute)[0] - if new_value: + if new_value != None: #pickle if anything else than str if type(new_value) != type(str()): new_value = pickle.dumps(new_value)#,pickle.HIGHEST_PROTOCOL) ispickled = True else: - new_value = new_value.strip() + new_value = new_value ispickled = False if attrib_obj: @@ -605,7 +601,7 @@ class Object(models.Model): new_attrib.save() elif attrib_obj: - # If you do something like @set me=attrib: , destroy the attrib. + # If you do something like @set me=attrib: , destroy the attrib. attrib_obj.delete() diff --git a/src/script_parents/basicobject.py b/src/script_parents/basicobject.py index 696dc5b229..7c4e111cc3 100644 --- a/src/script_parents/basicobject.py +++ b/src/script_parents/basicobject.py @@ -98,11 +98,11 @@ class EvenniaBasicObject(object): else: show_dbrefs = False - description = target_obj.get_description() + description = target_obj.get_attribute_value('desc') if description is not None: retval = "%s\r\n%s" % ( target_obj.get_name(show_dbref=show_dbrefs), - target_obj.get_description(), + target_obj.get_attribute_value('desc'), ) else: retval = "%s" % (