telestrial

Prompt after every command

Jun 7th, 2021 (edited)
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. #typeclasses/characters.py
  2. class Human(Character):
  3.     """
  4.    Implementation of Human Race in Wayward.
  5.    """
  6.     def at_object_creation(self):
  7.         #set persistent attributes
  8.         self.db.hp = 100
  9.         self.db.will = 1
  10.  
  11. #commands/command.py
  12. class MuxCommand(Command):
  13.     def at_post_cmd(self):
  14.         """
  15.        This hook is called after the command has finished executing
  16.        (after self.func()).
  17.        """
  18.         caller = self.caller
  19.         prompt = 'HP: %i WP: %i' % (caller.db.hp, caller.db.will)
  20.        
  21.         caller.msg(' ')
  22.         caller.msg(prompt=prompt)
  23.  
  24.        
  25. # In multisession mode = 2, the command of connecting account->character (@ic <charactername>) seems to be invoking MuxCommand, but, at the point of its execution, the character's attributes aren't initialized, so my at_post_cmd reference to caller.db.hp doesn't exist. It's a NoneType, not an Int. Maybe? Also, commands that use account, like who, also throw the same way.
Add Comment
Please, Sign In to add comment