Add display_name and disambiguation_tag for dynamic naming.
This commit is contained in:
parent
a5887d23e2
commit
1822b01086
6 changed files with 75 additions and 50 deletions
|
|
@ -610,3 +610,28 @@ class TypedObject(SharedMemoryModel):
|
|||
raise Exception("Cannot delete the ndb object!")
|
||||
ndb = property(__ndb_get, __ndb_set, __ndb_del)
|
||||
|
||||
def display_name(self, looker, **kwargs):
|
||||
"""
|
||||
Displays the name of the object in a viewer-aware manner.
|
||||
|
||||
Note that this function could be extended to change how object names
|
||||
appear to users, but be wary. This function does not change an object's keys or
|
||||
aliases when searching, and is expected to produce something useful for builders.
|
||||
"""
|
||||
if self.access(looker, access_type='controls'):
|
||||
return "{}(#{})".format(self.name, self.id)
|
||||
return self.name
|
||||
|
||||
def get_extra_info(self, viewer, **kwargs):
|
||||
"""
|
||||
Used when an object is in a list of ambiguous objects as an additional
|
||||
information tag.
|
||||
|
||||
For instance, if you had potions which could have varying levels of liquid
|
||||
left in them, you might want to display how many drinks are left in each when
|
||||
selecting which to drop, but not in your normal inventory listing.
|
||||
"""
|
||||
|
||||
if self.location == viewer:
|
||||
return " (carried)"
|
||||
return ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue