changeset 165:95461b06bac1

Added "Say" action.
author KarstenBock@gmx.net
date Thu, 15 Dec 2011 21:14:13 +0100
parents ed24962cdf5e
children a6bbb732b27b
files entities/action.py
diffstat 1 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/entities/action.py	Sat Nov 19 19:28:38 2011 +0100
+++ b/entities/action.py	Thu Dec 15 21:14:13 2011 +0100
@@ -581,6 +581,34 @@
                 Empty bottle"""))
         super(BrewBeerAction, self).execute()
 
+class SayAction(Action):
+    """Action that will display a short text over the entity and in the action
+    box."""
+
+    def __init__(self, controller, entity, text, commands = None):
+        """Basic action constructor
+        @param controller: A reference to the GameSceneController.
+        @type controller: parpg.GameSceneController
+        @param entity: The entity that says the text
+        @type script: parpg.entities.General
+        @param text: The text to be displayed
+        @type text: string
+        @param commands: Special commands that are executed
+        @type commands: Dictionary 
+        """
+        Action.__init__(self, controller, commands)
+        self.entity = entity
+        self.text = text
+    
+    def execute(self):
+        if self.entity.fifeagent:
+            self.entity.fifeagent.behaviour.agent.say(self.text);
+        if self.entity.description:
+            self.controller.view.hud.actions_box.addDialog(
+                self.entity.description.view_name,
+                self.text)
+        Action.execute(self)
+
 ACTIONS = {"ChangeMap":ChangeMapAction, 
            "Open":OpenAction,
            "Close":CloseAction,
@@ -597,5 +625,6 @@
            "BrewBeer":BrewBeerAction,
            "ExamineContents": ExamineContentsAction,
            "RunScript": RunScriptAction,
+           "Say" : SayAction,
            "None": Action,
            }