# HG changeset patch # User KarstenBock@gmx.net # Date 1321714832 -3600 # Node ID ee2d6835d87ae9f81ea4200ba4fa19c37eb8b479 # Parent d224bbce512af55c3d5f586cc869473f1233afe7 Added RunScriptAction class. diff -r d224bbce512a -r ee2d6835d87a entities/action.py --- 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, }