changeset 162:ee2d6835d87a

Added RunScriptAction class.
author KarstenBock@gmx.net
date Sat, 19 Nov 2011 16:00:32 +0100
parents d224bbce512a
children 9c82ed72dc9d
files entities/action.py
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/entities/action.py	Thu Nov 17 20:36:08 2011 +0100
+++ b/entities/action.py	Sat Nov 19 16:00:32 2011 +0100
@@ -437,6 +437,28 @@
         super(DropItemFromContainerAction, self).execute()
         container.remove_item(self.item.container, self.item.slot)
         self.container_gui.updateImages()
+
+class RunScriptAction(Action):
+    """Action that runs a specific script"""
+
+    def __init__(self, controller, script, commands = None):
+        """Basic action constructor
+        @param controller: A reference to the GameSceneController.
+        @type controller: parpg.GameSceneController
+        @param script: The name of the script to run.
+        @type script: string
+        @param commands: Special commands that are executed
+        @type commands: Dictionary 
+        """
+        self.commands = commands or ()
+        self.controller = controller
+        self.model = controller.model
+        self.script = script
+        self.executed = False
+    
+    def execute(self):
+        self.controller.systems.scripting.runScript(self.script)
+        Action.execute(self)
         
 class BrewBeerAction(Action):
     """Action for brewing beer in a pot"""
@@ -577,4 +599,5 @@
            "DropFromInventory":DropItemFromContainerAction,
            "BrewBeer":BrewBeerAction,
            "ExamineContents": ExamineContentsAction,
+           "RunScript": RunScriptAction,
            }