# HG changeset patch # User KarstenBock@gmx.net # Date 1323980053 -3600 # Node ID c0915e63a5571305a3a28fe1fca0011d297a4bc5 # Parent 13433b3e55cef446544a2aeb806521a8eec2f4c0 Added "Say" action. diff -r 13433b3e55ce -r c0915e63a557 .hgsubstate --- a/.hgsubstate Mon Dec 12 22:09:20 2011 +0100 +++ b/.hgsubstate Thu Dec 15 21:14:13 2011 +0100 @@ -1,2 +1,2 @@ -22 data +23 data 833aac39c9bd43873554f19ab3d6c27ddba317ff tools diff -r 13433b3e55ce -r c0915e63a557 src/parpg/entities/action.py --- a/src/parpg/entities/action.py Mon Dec 12 22:09:20 2011 +0100 +++ b/src/parpg/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, }