Mercurial > parpg-core
changeset 195:fabe303ab74f
Added RunScriptAction class.
author | KarstenBock@gmx.net |
---|---|
date | Sat, 19 Nov 2011 16:00:32 +0100 |
parents | 8dd835103854 |
children | 7e51bae477f7 |
files | src/parpg/entities/action.py |
diffstat | 1 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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, }