changeset 191:c97e48257f51

script commands are stored in the System now instead of the the script object.
author KarstenBock@gmx.net
date Sun, 13 Nov 2011 13:37:24 +0100
parents a22e92090018
children 191f89a22303
files src/parpg/systems/scriptingsystem.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/parpg/systems/scriptingsystem.py	Sat Nov 12 20:54:25 2011 +0100
+++ b/src/parpg/systems/scriptingsystem.py	Sun Nov 13 13:37:24 2011 +0100
@@ -17,12 +17,12 @@
 class Script(object):
     """Script object"""
 
-    def __init__(self, condition, actions, commands):
+    def __init__(self, condition, actions, system):
         """Constructor"""
         assert(isinstance(actions, deque))
         self.condition = condition
         self.actions = actions
-        self.commands = commands
+        self.system = system
         self.running = False
         self.finished = False
         self.time = 0
@@ -45,7 +45,10 @@
                 if len(action) >= 3:
                     vals = action[3:] if len(action) > 3 else ()
                     command = action[2]
-                    self.commands[command](*vals, action=self.cur_action)
+                    self.system.commands[command](
+                        *vals, 
+                        action=self.cur_action
+                    )
                 else:
                     self.cur_action.execute()
             except IndexError:
@@ -59,11 +62,12 @@
     their behavior.
     """
 
-    def __init__(self, funcs):
+    def __init__(self, funcs, commands):
         """Constructor"""
         self.funcs = funcs
         self.vals = {}
         self.scripts = []
+        self.commands = commands
 
     def step(self, dt):
         """Execute a time step for the system. Must be defined