[SOLVED] Character.Speaking never returns true (even in rep_ex_always)?

Started by monkey0506, Sun 16/08/2009 02:13:27

Previous topic - Next topic

monkey0506

Okay, perhaps I'm being a bit silly here, but I just had 3.1.2 installed, and I upgraded it to the latest beta. Neither version of the editor is giving the expected response.

This is literally the code I am using:

Code: ags
function on_key_press(eKeyCode keycode) {
  if (keycode == 'C') player.Say("BLAH BLAH BLAH!");
}

function repeatedly_execute_always() {
  if (player.Speaking) AbortGame("player speaking.");
}


The problem of course being that the game runs fine, no matter how many times I press the letter C. The player speaks normally and the AbortGame call is ignored...the Character.Speaking property as far as I can tell never returns true. ???

SSH

12

Shane 'ProgZmax' Stevens

I use character.speaking quite extensively in the game I've updated to the the latest build and it works fine for me.  It's a longshot, but the only thing I can think of is that the 'player' shortcut name isn't working.  Have you tried cBill.Speaking or Character[0] (or whatever)?  I never use the 'player' alternate, myself.

Pumaman

Seems fine for me too. Can you try putting a breakpoint on that line to make sure that the repeatedly_execute_always is actually being called?

monkey0506

I actually made sure that rep_ex_always was being called by adding an "AbortGame("");" immediately above the specified line. The game immediately crashed (aborted) as expected. I have tested this both with the player keyword and the character's script name directly...which is why I don't know what's going on. :-\

Joe

But a breakpoint could help, and always using this syntax:

Code: ags

function repeatedly_execute_always() {
  if (player.Speaking)
    AbortGame("player speaking.");//breakpoint line
}


AFAIK
Otherwise you'll never know if the conditional is returning true or false.
Copinstar © Oficial Site

monkey0506

Actually I do know the conditional is returning false simply based on the fact that the game is never aborting due to the character speaking.

And I did actually test it with a breakpoint and the conditional never returns true.

Edit: By the way SSH, I haven't tested it with SayBackground...however Character.Speaking specifically says it doesn't work with SayBackground.




I've now tested this on a different computer (this one has 3.2 BETA 2 installed). I am getting exactly the same results.

I have even gone as far as to create a new game (using the default template). I deleted all the GUIs and completely deleted the global script. I replaced it with the following:

Code: ags
function on_key_press(eKeyCode keycode) {
  if (keycode == 'C') {
    cEgo.Say("BLAH BLAH BLAH BLAH BLAH BLAH BLAH!");
  }
}

bool b = false;

function repeatedly_execute_always() {
  if (cEgo.Speaking) {
    AbortGame("player speaking.");
  }
  else if (!IsInterfaceEnabled()) {
    if (b) {
      AbortGame("gameplay interrupted.");
    }
    else {
      b = true;
    }
  }
}


I used b to make sure at least one loop passed from the time the character started speaking, to ensure all variables had the chance to be updated properly. Character.Speaking (in this case, cEgo.Speaking) never returns true in this instance. The game aborts immediately after the text appears on-screen. It gives the message that the gameplay was interrupted.

As I said this is on an entirely different computer using a brand new game project... :-\

I've uploaded the entire source of said project here. This was last saved with AGS 3.2 BETA 2 so it may give you a warning about upgrading it. These are the exact circumstances in which I am experiencing the problem: Load the Game.agf file, Run (with debugger), press the letter 'C' on the keyboard. The player starts speaking, but cEgo.Speaking is never (apparently) set to true.

Just as a point of interest, I compiled the game, ran it, and got:

Quote---------------------------
Adventure Game Studio
---------------------------
A fatal error has been generated by the script using the AbortGame function. Please contact the game author for support.

in "GlobalScript.asc", line 17

Error: gameplay interrupted.

---------------------------
OK   
---------------------------

Pumaman

Ah, this is because the character doens't have a SpeechView. In your test game if I change the SpeechView to 1 it works.

I'm not sure if this is a bug or just something that should be clarified in the documentation for the SpeechView property. The way the engine sees it, if the character is not animating then they are not actually "speaking".

monkey0506

Okay that makes sense. Thanks for clarifying that...I don't really know what the "best" behavior here would be myself, although the character is speaking in a blocking fashion so it might make sense for this to be updated. I doubt anyone would really rely on this behavior.

Again, thanks for looking into it.

SMF spam blocked by CleanTalk