"""TraitRoomAllows for a (very simple) bool based expanded descriptionsThis allows for scripts to place traits in the room, and if a trait is presentshow the corresponding description stored in a dict.Further things that you could add: A command to set/delete a trait A command to add/delete/edit the trait descriptions Simple functions as traits (ex $player_name)Note the output is a complete mess and will have to be adjusted."""fromevenniaimportDefaultRoomclassTraitRoom(DefaultRoom):""" """defat_object_creation(self):super(TraitRoom,self).at_object_creation()self.db.traits=[]self.db.trait_desc={}defreturn_appearance(self,looker):""" This is called when e.g. the look command wants to retrieve the description of this object. Args: looker (Object): The object looking at us. Returns: description (str): Our description """# all of the functions must be in the form f(looker)room_functions={'$player_name':player_name}# get the legacy descreply=super(TraitRoom,self).return_appearance(looker)fortraitinself.db.traits:iftraitinroom_functions:reply+=room_functions[trait](looker)eliftraitinself.db.trait_desc:reply+=self.db.trait_desc[trait]returnreplydefplayer_name(looker):""" Return the name of the looker Args: looker (Object): The object looking Return: (str): the looker's name """returnlooker.name
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.