comparison entities/action.py @ 162:ee2d6835d87a

Added RunScriptAction class.
author KarstenBock@gmx.net
date Sat, 19 Nov 2011 16:00:32 +0100
parents 04854cf6e1ac
children 9c82ed72dc9d
comparison
equal deleted inserted replaced
161:d224bbce512a 162:ee2d6835d87a
435 435
436 def execute(self): 436 def execute(self):
437 super(DropItemFromContainerAction, self).execute() 437 super(DropItemFromContainerAction, self).execute()
438 container.remove_item(self.item.container, self.item.slot) 438 container.remove_item(self.item.container, self.item.slot)
439 self.container_gui.updateImages() 439 self.container_gui.updateImages()
440
441 class RunScriptAction(Action):
442 """Action that runs a specific script"""
443
444 def __init__(self, controller, script, commands = None):
445 """Basic action constructor
446 @param controller: A reference to the GameSceneController.
447 @type controller: parpg.GameSceneController
448 @param script: The name of the script to run.
449 @type script: string
450 @param commands: Special commands that are executed
451 @type commands: Dictionary
452 """
453 self.commands = commands or ()
454 self.controller = controller
455 self.model = controller.model
456 self.script = script
457 self.executed = False
458
459 def execute(self):
460 self.controller.systems.scripting.runScript(self.script)
461 Action.execute(self)
440 462
441 class BrewBeerAction(Action): 463 class BrewBeerAction(Action):
442 """Action for brewing beer in a pot""" 464 """Action for brewing beer in a pot"""
443 def __init__(self, controller, pot, commands = None): 465 def __init__(self, controller, pot, commands = None):
444 super(BrewBeerAction, self).__init__(controller, commands) 466 super(BrewBeerAction, self).__init__(controller, commands)
575 "Use":UseAction, 597 "Use":UseAction,
576 "PickUp":PickUpAction, 598 "PickUp":PickUpAction,
577 "DropFromInventory":DropItemFromContainerAction, 599 "DropFromInventory":DropItemFromContainerAction,
578 "BrewBeer":BrewBeerAction, 600 "BrewBeer":BrewBeerAction,
579 "ExamineContents": ExamineContentsAction, 601 "ExamineContents": ExamineContentsAction,
602 "RunScript": RunScriptAction,
580 } 603 }