contrib/extended_room.py code, markup updates
Whitespace edits, also
This commit is contained in:
parent
78ff1f39a0
commit
c100a7765c
1 changed files with 15 additions and 17 deletions
|
|
@ -108,7 +108,7 @@ class ExtendedRoom(DefaultRoom):
|
||||||
look command.
|
look command.
|
||||||
"""
|
"""
|
||||||
def at_object_creation(self):
|
def at_object_creation(self):
|
||||||
"Called when room is first created only."
|
"""Called when room is first created only."""
|
||||||
self.db.spring_desc = ""
|
self.db.spring_desc = ""
|
||||||
self.db.summer_desc = ""
|
self.db.summer_desc = ""
|
||||||
self.db.autumn_desc = ""
|
self.db.autumn_desc = ""
|
||||||
|
|
@ -367,12 +367,12 @@ class CmdExtendedDesc(default_cmds.CmdDesc):
|
||||||
aliases = ["@describe", "@detail"]
|
aliases = ["@describe", "@detail"]
|
||||||
|
|
||||||
def reset_times(self, obj):
|
def reset_times(self, obj):
|
||||||
"By deleteting the caches we force a re-load."
|
"""By deleteting the caches we force a re-load."""
|
||||||
obj.ndb.last_season = None
|
obj.ndb.last_season = None
|
||||||
obj.ndb.last_timeslot = None
|
obj.ndb.last_timeslot = None
|
||||||
|
|
||||||
def func(self):
|
def func(self):
|
||||||
"Define extended command"
|
"""Define extended command"""
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
location = caller.location
|
location = caller.location
|
||||||
if self.cmdstring == '@detail':
|
if self.cmdstring == '@detail':
|
||||||
|
|
@ -393,13 +393,14 @@ class CmdExtendedDesc(default_cmds.CmdDesc):
|
||||||
if not self.args:
|
if not self.args:
|
||||||
# No args given. Return all details on location
|
# No args given. Return all details on location
|
||||||
string = "|wDetails on %s|n:" % location
|
string = "|wDetails on %s|n:" % location
|
||||||
details = "\n".join(" |w%s|n: %s" % (key, utils.crop(text)) for key, text in location.db.details.items())
|
details = "\n".join(" |w%s|n: %s"
|
||||||
|
% (key, utils.crop(text)) for key, text in location.db.details.items())
|
||||||
caller.msg("%s\n%s" % (string, details) if details else "%s None." % string)
|
caller.msg("%s\n%s" % (string, details) if details else "%s None." % string)
|
||||||
return
|
return
|
||||||
if not self.rhs:
|
if not self.rhs:
|
||||||
# no '=' used - list content of given detail
|
# no '=' used - list content of given detail
|
||||||
if self.args in location.db.details:
|
if self.args in location.db.details:
|
||||||
string = "{wDetail '%s' on %s:\n{n" % (self.args, location)
|
string = "|wDetail '%s' on %s:\n|n" % (self.args, location)
|
||||||
string += str(location.db.details[self.args])
|
string += str(location.db.details[self.args])
|
||||||
caller.msg(string)
|
caller.msg(string)
|
||||||
else:
|
else:
|
||||||
|
|
@ -414,18 +415,15 @@ class CmdExtendedDesc(default_cmds.CmdDesc):
|
||||||
# we are doing a @desc call
|
# we are doing a @desc call
|
||||||
if not self.args:
|
if not self.args:
|
||||||
if location:
|
if location:
|
||||||
string = "{wDescriptions on %s{n:\n" % location.key
|
string = "|wDescriptions on %s|n:\n" % location.key
|
||||||
string += " {wspring:{n %s\n" % location.db.spring_desc
|
string += " |wspring:|n %s\n" % location.db.spring_desc
|
||||||
string += " {wsummer:{n %s\n" % location.db.summer_desc
|
string += " |wsummer:|n %s\n" % location.db.summer_desc
|
||||||
string += " {wautumn:{n %s\n" % location.db.autumn_desc
|
string += " |wautumn:|n %s\n" % location.db.autumn_desc
|
||||||
string += " {wwinter:{n %s\n" % location.db.winter_desc
|
string += " |wwinter:|n %s\n" % location.db.winter_desc
|
||||||
string += " {wgeneral:{n %s" % location.db.general_desc
|
string += " |wgeneral:|n %s" % location.db.general_desc
|
||||||
caller.msg(string)
|
caller.msg(string)
|
||||||
return
|
return
|
||||||
if self.switches and self.switches[0] in ("spring",
|
if self.switches and self.switches[0] in ("spring", "summer", "autumn", "winter"):
|
||||||
"summer",
|
|
||||||
"autumn",
|
|
||||||
"winter"):
|
|
||||||
# a seasonal switch was given
|
# a seasonal switch was given
|
||||||
if self.rhs:
|
if self.rhs:
|
||||||
caller.msg("Seasonal descs only works with rooms, not objects.")
|
caller.msg("Seasonal descs only works with rooms, not objects.")
|
||||||
|
|
@ -455,7 +453,7 @@ class CmdExtendedDesc(default_cmds.CmdDesc):
|
||||||
else:
|
else:
|
||||||
text = self.args
|
text = self.args
|
||||||
obj = location
|
obj = location
|
||||||
obj.db.desc = text # a compatibility fallback
|
obj.db.desc = text # a compatibility fallback
|
||||||
if obj.attributes.has("general_desc"):
|
if obj.attributes.has("general_desc"):
|
||||||
obj.db.general_desc = text
|
obj.db.general_desc = text
|
||||||
self.reset_times(obj)
|
self.reset_times(obj)
|
||||||
|
|
@ -481,7 +479,7 @@ class CmdGameTime(default_cmds.MuxCommand):
|
||||||
help_category = "General"
|
help_category = "General"
|
||||||
|
|
||||||
def func(self):
|
def func(self):
|
||||||
"Reads time info from current room"
|
"""Reads time info from current room"""
|
||||||
location = self.caller.location
|
location = self.caller.location
|
||||||
if not location or not hasattr(location, "get_time_and_season"):
|
if not location or not hasattr(location, "get_time_and_season"):
|
||||||
self.caller.msg("No location available - you are outside time.")
|
self.caller.msg("No location available - you are outside time.")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue