Changeset 220


Ignore:
Timestamp:
08/04/09 05:02:45 (10 years ago)
Author:
bretzel_parpg
Message:

Added a simple console. To show/hide it press F10. Right now only quit and exit are valid
commands. Fixes #75.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/run.py

    r157 r220  
    6161           @return: None""" 
    6262        self.quit = True 
     63 
     64    def onConsoleCommand(self, command): 
     65        """ 
     66        Called on every console comand 
     67        @type command: string 
     68        @param command: the command to run 
     69        @return: result 
     70        """ 
     71        if (command.lower() in ('quit', 'exit')): 
     72            self.quitGame() 
     73                    
     74        else: 
     75            try: 
     76                result = str(eval(command)) 
     77            except Exception, e: 
     78                result = str(e) 
     79 
     80        if not result: 
     81            result = 'no result' 
     82         
     83        return result 
    6384 
    6485    def onCommand(self, command): 
Note: See TracChangeset for help on using the changeset viewer.