Moved the object's 'description' into an attribute, as suggested in the code. This means that get_description() and set_description() should no longer be used; instead use set_attribute('desc',value) and get_attribute('desc') as you would any attribute. 'desc' is used by the default look command, but apart from that, desc has no special status anymore.
/Griatch
This commit is contained in:
parent
e7d7284d5c
commit
05554e290a
7 changed files with 45 additions and 49 deletions
|
|
@ -35,7 +35,6 @@ from src.statetable import GLOBAL_STATE_TABLE
|
||||||
#the name of our state, to make sure it's the same everywhere
|
#the name of our state, to make sure it's the same everywhere
|
||||||
STATENAME = 'menu'
|
STATENAME = 'menu'
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# 'entry' command
|
# 'entry' command
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class RedButton(BasicObject):
|
||||||
#get stored object related to this class
|
#get stored object related to this class
|
||||||
obj = self.scripted_obj
|
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("breakpoint", 10)
|
||||||
obj.set_attribute("count", 0)
|
obj.set_attribute("count", 0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ def cmd_examine(command):
|
||||||
s += str(target_obj.get_name(fullname=True)) + newl
|
s += str(target_obj.get_name(fullname=True)) + newl
|
||||||
s += str("Type: %s Flags: %s" % (target_obj.get_type(),
|
s += str("Type: %s Flags: %s" % (target_obj.get_type(),
|
||||||
target_obj.get_flags())) + newl
|
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("Owner: %s " % target_obj.get_owner()) + newl
|
||||||
s += str("Zone: %s" % target_obj.get_zone()) + newl
|
s += str("Zone: %s" % target_obj.get_zone()) + newl
|
||||||
s += str("Parent: %s " % target_obj.get_script_parent()) + newl
|
s += str("Parent: %s " % target_obj.get_script_parent()) + newl
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,7 @@ def cmd_create(command):
|
||||||
"location": source_object,
|
"location": source_object,
|
||||||
"owner": source_object}
|
"owner": source_object}
|
||||||
new_object = Object.objects.create_object(odat)
|
new_object = Object.objects.create_object(odat)
|
||||||
|
new_object.set_attribute('desc', 'Nothing special.')
|
||||||
if len(eq_args)>1:
|
if len(eq_args)>1:
|
||||||
parent_str = eq_args[1]
|
parent_str = eq_args[1]
|
||||||
if parent_str and new_object.set_script_parent(parent_str):
|
if parent_str and new_object.set_script_parent(parent_str):
|
||||||
|
|
@ -797,12 +797,12 @@ def cmd_description(command):
|
||||||
return
|
return
|
||||||
|
|
||||||
new_desc = eq_args[1]
|
new_desc = eq_args[1]
|
||||||
if new_desc == '':
|
if not new_desc:
|
||||||
source_object.emit_to("%s - DESCRIPTION cleared." % target_obj)
|
source_object.emit_to("%s - description cleared." % target_obj)
|
||||||
target_obj.set_description(None)
|
target_obj.set_attribute('desc', 'Nothing special.')
|
||||||
else:
|
else:
|
||||||
source_object.emit_to("%s - DESCRIPTION set." % target_obj)
|
source_object.emit_to("%s - description set." % target_obj)
|
||||||
target_obj.set_description(new_desc)
|
target_obj.set_attribute('desc', new_desc)
|
||||||
GLOBAL_CMD_TABLE.add_command("@describe", cmd_description)
|
GLOBAL_CMD_TABLE.add_command("@describe", cmd_description)
|
||||||
|
|
||||||
def cmd_recover(command):
|
def cmd_recover(command):
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ def create_objects():
|
||||||
# Create the matching PLAYER object in the object DB.
|
# Create the matching PLAYER object in the object DB.
|
||||||
god_user_obj = Object(id=1, type=defines_global.OTYPE_PLAYER)
|
god_user_obj = Object(id=1, type=defines_global.OTYPE_PLAYER)
|
||||||
god_user_obj.set_name(god_user.username)
|
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.scriptlink.at_player_creation()
|
||||||
god_user_obj.save()
|
god_user_obj.save()
|
||||||
|
|
||||||
|
|
@ -40,7 +41,7 @@ def create_objects():
|
||||||
limbo_obj = Object(id=2, type=defines_global.OTYPE_ROOM)
|
limbo_obj = Object(id=2, type=defines_global.OTYPE_ROOM)
|
||||||
limbo_obj.set_owner(god_user_obj)
|
limbo_obj.set_owner(god_user_obj)
|
||||||
limbo_obj.set_name('%ch%ccLimbo%cn')
|
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.scriptlink.at_object_creation()
|
||||||
limbo_obj.save()
|
limbo_obj.save()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,10 @@ class Object(models.Model):
|
||||||
script_parent = models.CharField(max_length=255, 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)
|
home = models.ForeignKey('self', related_name="obj_home", blank=True, null=True)
|
||||||
type = models.SmallIntegerField(choices=defines_global.OBJECT_TYPES)
|
type = models.SmallIntegerField(choices=defines_global.OBJECT_TYPES)
|
||||||
|
|
||||||
# TODO: Move description to an attribute.
|
# 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)
|
location = models.ForeignKey('self', related_name="obj_location", blank=True, null=True)
|
||||||
flags = models.TextField(blank=True, null=True)
|
flags = models.TextField(blank=True, null=True)
|
||||||
nosave_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 system can set a particular command table to be used.
|
||||||
state = None
|
state = None
|
||||||
|
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
"""
|
"""
|
||||||
Used to figure out if one object is the same as another.
|
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],
|
return "%s%s" % (parse_ansi(name_string.split(';')[0],
|
||||||
strip_ansi=no_ansi), dbref_string)
|
strip_ansi=no_ansi), dbref_string)
|
||||||
|
|
||||||
def set_description(self, new_desc):
|
## def set_description(self, new_desc=''):
|
||||||
"""
|
## """
|
||||||
Set an objects description
|
## Set an objects description
|
||||||
"""
|
## """
|
||||||
if new_desc == '':
|
## if not new_desc:
|
||||||
self.description = None
|
## self.set_attribute('desc', 'Nothing special')
|
||||||
else:
|
## #self.description = None
|
||||||
self.description = new_desc
|
## else:
|
||||||
self.save()
|
## self.set_attribute('desc', new_desc)
|
||||||
|
## #self.description = new_desc
|
||||||
|
## self.save()
|
||||||
|
|
||||||
def get_description(self, no_parsing=False, wrap_text=False):
|
## def get_description(self, no_parsing=False, wrap_text=False):
|
||||||
"""
|
## """
|
||||||
Returns an object's ANSI'd description or None if description is not
|
## Returns an object's ANSI'd description or None if description is not
|
||||||
set.
|
## set.
|
||||||
"""
|
## """
|
||||||
try:
|
## desc = self.get_attribute_value('desc')
|
||||||
# If no description is set, return None
|
## if desc:
|
||||||
if self.description is None:
|
## if not no_parsing:
|
||||||
return None
|
## desc = parse_ansi(desc)
|
||||||
# Evaluate ANSI and stuff?
|
## if wrap_text:
|
||||||
if no_parsing:
|
## return functions_general.word_wrap(desc)
|
||||||
retval = self.description
|
## else:
|
||||||
else:
|
## return desc
|
||||||
retval = parse_ansi(self.description)
|
## else:
|
||||||
|
## # No description attribute present, return empty string.
|
||||||
# Default to a 78 character wrap.
|
## return ""
|
||||||
if wrap_text:
|
|
||||||
return functions_general.word_wrap(retval)
|
|
||||||
else:
|
|
||||||
return retval
|
|
||||||
except:
|
|
||||||
# No description attribute present, return empty string.
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_flags(self):
|
def get_flags(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -580,13 +576,13 @@ class Object(models.Model):
|
||||||
attrib_obj = \
|
attrib_obj = \
|
||||||
Attribute.objects.filter(attr_object=self).filter(attr_name__iexact=attribute)[0]
|
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
|
#pickle if anything else than str
|
||||||
if type(new_value) != type(str()):
|
if type(new_value) != type(str()):
|
||||||
new_value = pickle.dumps(new_value)#,pickle.HIGHEST_PROTOCOL)
|
new_value = pickle.dumps(new_value)#,pickle.HIGHEST_PROTOCOL)
|
||||||
ispickled = True
|
ispickled = True
|
||||||
else:
|
else:
|
||||||
new_value = new_value.strip()
|
new_value = new_value
|
||||||
ispickled = False
|
ispickled = False
|
||||||
|
|
||||||
if attrib_obj:
|
if attrib_obj:
|
||||||
|
|
|
||||||
|
|
@ -98,11 +98,11 @@ class EvenniaBasicObject(object):
|
||||||
else:
|
else:
|
||||||
show_dbrefs = False
|
show_dbrefs = False
|
||||||
|
|
||||||
description = target_obj.get_description()
|
description = target_obj.get_attribute_value('desc')
|
||||||
if description is not None:
|
if description is not None:
|
||||||
retval = "%s\r\n%s" % (
|
retval = "%s\r\n%s" % (
|
||||||
target_obj.get_name(show_dbref=show_dbrefs),
|
target_obj.get_name(show_dbref=show_dbrefs),
|
||||||
target_obj.get_description(),
|
target_obj.get_attribute_value('desc'),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
retval = "%s" % (
|
retval = "%s" % (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue