# HG changeset patch # User KarstenBock@gmx.net # Date 1323980053 -3600 # Node ID 95461b06bac16531a459605bf0714e9f5308e16c # Parent ed24962cdf5e822651ab1e4b5bc28de478af2289 Added "Say" action. diff -r ed24962cdf5e -r 95461b06bac1 entities/action.py --- 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, }