diff gamescenecontroller.py @ 161:d224bbce512a

Implemented loading scripts from files.
author KarstenBock@gmx.net
date Thu, 17 Nov 2011 20:36:08 +0100
parents 75c0b728ccf3
children b3b82c2aebee
line wrap: on
line diff
--- a/gamescenecontroller.py	Sun Nov 13 17:19:14 2011 +0100
+++ b/gamescenecontroller.py	Thu Nov 17 20:36:08 2011 +0100
@@ -355,10 +355,10 @@
                 )
                 for obj in deleted:
                     obj.delete()
+            self.model.loadMap(self.model.target_map_name)
+            self.setupScripts(self.model.target_map_name)
             
-            self.model.loadMap(self.model.target_map_name)
-            
-            self.model.setActiveMap(self.model.target_map_name)          
+            self.model.setActiveMap(self.model.target_map_name, self)          
             
             self.model.placeAgents(self)
             self.model.placePC(self)
@@ -372,6 +372,11 @@
             self.view.hud.initializeInventory()         
             self.pause(False)
 
+    def setupScripts(self, map_name):
+        """Read scripts for the current map"""
+        self.systems.scripting.reset()
+        self.model.readScriptsOfMap(map_name, self)
+
     def handleScrolling(self):
         """
         Merge kb and mouse related scroll data, limit the speed and
@@ -538,6 +543,7 @@
             self.model.loadMap(self.model.game_state.current_map_name)   
         self.model.placeAgents(self)
         self.model.placePC(self)
+        self.setupScripts(self.model.game_state.current_map_name)
         self.view.hud.initializeInventory()          
 
     def quitGame(self):