Question re: Character.Say()

Started by wynni2, Tue 10/04/2018 01:05:44

Previous topic - Next topic

wynni2

Hi all -

When I pass the command player.Say(string message), does "message" get stored in a way that's retrievable? For example, if I wanted another character to repeat whatever the player was saying, could I retrieve "message"  from the engine and then pass it to Parrot.Say(message)?

I know this could be done by declaring the player's dialog in local strings first, but I'm wondering about a more general approach.

Thanks.

Khris

It sounds like you're looking for custom functions, in this case a customized Say() command. This is possible, sort of. (If you want your custom speech to be used for every line in the game, one major downside is that you can no longer use standard lines in dialog scripts; all spoken lines need to be using the custom function.)

Example:
Code: ags
// header
import void S(this Character*, String message);

// main script
void S(this Character*, String message) {
  this.Say(message);
  if (player.Room == cParrot.Room) cParrot.Say(message);
}


By using player.S("Hello"); the parrot will now automatically repeat whatever the player says.

wynni2

The issue you bring up with not being able to use the dialog system was exactly my concern. Thanks for the suggestion.

Khris

To be perfectly clear, you can use the dialog system with a custom function, just not the usual way.

Dialog script example
Code: ags
// this calls player.Say() and can no longer be used
player: Hello

// this has to be used instead
 player.S("Hello");

SMF spam blocked by CleanTalk