# HG changeset patch # User KarstenBock@gmx.net # Date 1321714832 -3600 # Node ID fabe303ab74f37902f0b9e1d77be841b0e94362e # Parent 8dd835103854972aab6d941b210d79a77ac03d00 Added RunScriptAction class. diff -r 8dd835103854 -r fabe303ab74f src/parpg/entities/action.py --- a/src/parpg/entities/action.py Thu Nov 17 21:21:22 2011 +0100 +++ b/src/parpg/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, }