diff console.py @ 183:7b6aba7839ea

getGameEnvironment of GameState now returns a locals dictionary that is empty at the beginning of the game and will be saved in save games. The vals and funcs are now both in the globals dictionary. This WILL break old saves.
author Beliar <KarstenBock@gmx.net>
date Thu, 15 Mar 2012 16:24:05 +0100
parents c706963ed0c3
children
line wrap: on
line diff
--- a/console.py	Thu Mar 15 14:30:37 2012 +0100
+++ b/console.py	Thu Mar 15 16:24:05 2012 +0100
@@ -96,15 +96,13 @@
         return res
 
     def handlePython(self,command):
-        console_locals = {
+        globals, locals = self.game_state.getGameEnvironment()
+        globals.update({
                         "__name__":"__paprg_console__",
                         "__doc__": None,
-                        }
-        vals, funcs = self.game_state.getGameEnvironment()
-        console_locals.update(vals)
-        console_locals.update(funcs)
+                        })
 
-        console = code.InteractiveConsole(console_locals)
+        console = code.InteractiveConsole(globals, locals)
 
         user_code = command[7:len(command)]
 
@@ -114,17 +112,9 @@
         sys.stdout = codeOut
         sys.stderr = codeOut
 
-        #Workaround it not being possible to enter a blank line in the console
-        if user_code == " ":
-            user_code = ""
-
         #Process the code
         console.push(user_code)
-        if len(console.buffer) == 0:
-            output = codeOut.getvalue()
-        else:
-            output =  "..."
-
+        output = codeOut.getvalue()
 
         #restore stdout and stderr
         sys.stdout = sys.__stdout__