player.Speaking

Started by Vincent, Sun 24/01/2021 09:05:37

Previous topic - Next topic

Vincent

Good day to all Agser,
I am trying to do something simple but I am having some troubles. I am trying to write a simple function which handle repeatedly the portrait position by using Sierra with Background. I would like to do that when the player is speaking to place the portrait to the left side otherwhise to place it to the right side. I've been writing something like this which doesn't seems to be working fine for some reason:

Code: ags

function PlacePortrait()
{
  if (player.Speaking) SetGameOption(OPT_PORTRAITPOSITION, 0);
  else SetGameOption(OPT_PORTRAITPOSITION, 1);
}


For some reason using this function when the player speaks the portrait goes first right then left and right again... I would like to avoid to go for each line of dialog and add "SetGameOption(OPT_PORTRAITPOSITION, 0);" manually before the player or npc is speaking, apparently that seems to be the only way to make it work fine... I've also tried to change in general setting the sierra-style portrait location to be alternate but that doesn't change anything. Some of you has any suggestion on how to do this properly?

:EDIT:
quote from the manual:
Quote
Sierra-style portrait location - if you're using Sierra-style speech, then this determines whether the portrait appears on the left or the right of the screen. The "alternate" setting means it swaps sides whenever a different person talks

I tested this as I said but it doesn't change anything which is strange.


:EDIT 2:
I guess at the moment I got it solved by writing an extended functions for player and npc when they are speaking, something like:
Code: ags

function PlayerSay (this Character*, String message) 
{  
   SetGameOption(OPT_PORTRAITPOSITION, 0);
   this.Say("%s", message);
}

Khris

I guess you're calling this in repeatedly_execute, at which point AGS has probably already read the option, so you're setting it too late.
I've never used portrait speech, so I can't help any further than that.

Vincent

Thanks Khris for answering, by the way yes, I was calling that function inside repeatedly execute. I too had the same feeling that by doing so maybe I was calling the function too late after ags had already executed the sentence itself, so maybe for that reason it was acting weird. However in general setting there's the "alternate" option at the sierra-style portrait position to swaps the portraits sides whenever a different person talks but that didn't work at all, I dont know if it is just me cause I tried that but it didn't change anything. Also at first I tried late repeatedly execute always because the manual say:

Quote
Character.Speaking
Since this property will only be true while the character is speaking, and speaking is a blocking command, this property will probably only be useful to access from the repeatedly_execute_always or late_repeatedly_execute_always handlers.

But I had the same result at all. However implementing an extended functions for characters it works just fine.

.M.M.

Just a small tip, Vincent, maybe it'll be helpful. You can keep just one Say function and set the portrait location from within it:

Code: ags
function SayPortrait(this Character*, String message) 
{  
 if (this == player) SetGameOption(OPT_PORTRAITPOSITION, 0);
 else SetGameOption(OPT_PORTRAITPOSITION, 1);
 this.Say("%s", message);
} 

SMF spam blocked by CleanTalk