Allow customizations of default descriptions
This commit is contained in:
parent
d76bc1a62b
commit
effe4c4a0a
2 changed files with 27 additions and 17 deletions
|
|
@ -693,6 +693,7 @@ class CmdCreate(ObjManipCommand):
|
||||||
)
|
)
|
||||||
if errors:
|
if errors:
|
||||||
self.msg(errors)
|
self.msg(errors)
|
||||||
|
|
||||||
if not obj:
|
if not obj:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -702,9 +703,7 @@ class CmdCreate(ObjManipCommand):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
string = f"You create a new {obj.typename}: {obj.name}."
|
string = f"You create a new {obj.typename}: {obj.name}."
|
||||||
# set a default desc
|
|
||||||
if not obj.db.desc:
|
|
||||||
obj.db.desc = "You see nothing special."
|
|
||||||
if "drop" in self.switches:
|
if "drop" in self.switches:
|
||||||
if caller.location:
|
if caller.location:
|
||||||
obj.home = caller.location
|
obj.home = caller.location
|
||||||
|
|
|
||||||
|
|
@ -397,6 +397,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
|
|
||||||
objects = ObjectManager()
|
objects = ObjectManager()
|
||||||
|
|
||||||
|
# Used by get_display_desc when self.db.desc is None
|
||||||
|
default_description = _("You see nothing special.")
|
||||||
|
|
||||||
# populated by `return_appearance`
|
# populated by `return_appearance`
|
||||||
appearance_template = """
|
appearance_template = """
|
||||||
{header}
|
{header}
|
||||||
|
|
@ -1464,10 +1467,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
if account:
|
if account:
|
||||||
obj.db.creator_id = account.id
|
obj.db.creator_id = account.id
|
||||||
|
|
||||||
# Set description if there is none, or update it if provided
|
# Set description if provided
|
||||||
if description or not obj.db.desc:
|
if description:
|
||||||
desc = description if description else "You see nothing special."
|
obj.db.desc = description
|
||||||
obj.db.desc = desc
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append(f"An error occurred while creating this '{key}' object: {e}")
|
errors.append(f"An error occurred while creating this '{key}' object: {e}")
|
||||||
|
|
@ -1746,7 +1748,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
str: The desc display string.
|
str: The desc display string.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.db.desc or "You see nothing special."
|
return self.db.desc or self.default_description
|
||||||
|
|
||||||
def get_display_exits(self, looker, **kwargs):
|
def get_display_exits(self, looker, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
@ -3004,6 +3006,9 @@ class DefaultCharacter(DefaultObject):
|
||||||
"edit:pid({account_id}) or perm(Admin)"
|
"edit:pid({account_id}) or perm(Admin)"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Used by get_display_desc when self.db.desc is None
|
||||||
|
default_description = _("This is a character.")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_default_lockstring(
|
def get_default_lockstring(
|
||||||
cls, account: "DefaultAccount" = None, caller: "DefaultObject" = None, **kwargs
|
cls, account: "DefaultAccount" = None, caller: "DefaultObject" = None, **kwargs
|
||||||
|
|
@ -3117,9 +3122,9 @@ class DefaultCharacter(DefaultObject):
|
||||||
if locks:
|
if locks:
|
||||||
obj.locks.add(locks)
|
obj.locks.add(locks)
|
||||||
|
|
||||||
# If no description is set, set a default description
|
# Set description if provided
|
||||||
if description or not obj.db.desc:
|
if description:
|
||||||
obj.db.desc = description if description else _("This is a character.")
|
obj.db.desc = description
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append(f"An error occurred while creating object '{key} object: {e}")
|
errors.append(f"An error occurred while creating object '{key} object: {e}")
|
||||||
|
|
@ -3330,6 +3335,9 @@ class DefaultRoom(DefaultObject):
|
||||||
# Generally, a room isn't expected to HAVE a location, but maybe in some games?
|
# Generally, a room isn't expected to HAVE a location, but maybe in some games?
|
||||||
_content_types = ("room",)
|
_content_types = ("room",)
|
||||||
|
|
||||||
|
# Used by get_display_desc when self.db.desc is None
|
||||||
|
default_description = _("This is a room.")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(
|
def create(
|
||||||
cls,
|
cls,
|
||||||
|
|
@ -3400,9 +3408,9 @@ class DefaultRoom(DefaultObject):
|
||||||
if account:
|
if account:
|
||||||
obj.db.creator_id = account.id
|
obj.db.creator_id = account.id
|
||||||
|
|
||||||
# If no description is set, set a default description
|
# Set description if provided
|
||||||
if description or not obj.db.desc:
|
if description:
|
||||||
obj.db.desc = description if description else _("This is a room.")
|
obj.db.desc = description
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append(f"An error occurred while creating this '{key}' object: {e}")
|
errors.append(f"An error occurred while creating this '{key}' object: {e}")
|
||||||
|
|
@ -3495,6 +3503,9 @@ class DefaultExit(DefaultObject):
|
||||||
exit_command = ExitCommand
|
exit_command = ExitCommand
|
||||||
priority = 101
|
priority = 101
|
||||||
|
|
||||||
|
# Used by get_display_desc when self.db.desc is None
|
||||||
|
default_description = _("This is an exit.")
|
||||||
|
|
||||||
# Helper classes and methods to implement the Exit. These need not
|
# Helper classes and methods to implement the Exit. These need not
|
||||||
# be overloaded unless one want to change the foundation for how
|
# be overloaded unless one want to change the foundation for how
|
||||||
# Exits work. See the end of the class for hook methods to overload.
|
# Exits work. See the end of the class for hook methods to overload.
|
||||||
|
|
@ -3609,9 +3620,9 @@ class DefaultExit(DefaultObject):
|
||||||
if account:
|
if account:
|
||||||
obj.db.creator_id = account.id
|
obj.db.creator_id = account.id
|
||||||
|
|
||||||
# If no description is set, set a default description
|
# Set description if provided
|
||||||
if description or not obj.db.desc:
|
if description:
|
||||||
obj.db.desc = description if description else _("This is an exit.")
|
obj.db.desc = description
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append(f"An error occurred while creating this '{key}' object: {e}")
|
errors.append(f"An error occurred while creating this '{key}' object: {e}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue