Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gumustdo on Sun 27/09/2009 06:00:56

Title: Letter by letter msg display, Does it possible ?
Post by: Gumustdo on Sun 27/09/2009 06:00:56
Hello,
I've tried out AGS quite a bit week ago. And have a questing about text/dialog displaying.
Dialog are displayed all sentence/speech at once. Does is possible to make it display letter by letter like SNES's RPG style?

Here's an example from ClockTower[SNES]
http://www.youtube.com/watch?v=Ng72snjGLCU

Thanks in advance ;)
Title: Re: Letter by letter msg display, Does it possible ?
Post by: tzachs on Sun 27/09/2009 12:26:50
Here is something to start with, put in globalscript.asc:


function SayLetterByLetter(this Character*, String sentence)

  String builder = "";
  int i=0;
  while (i < sentence.Length) 
  {
    builder = builder.AppendChar(sentence.Chars[i]);
    this.SayBackground(String.Format("%s", builder));   
    Wait(5);
    i++;
  }
  Wait(40); 
}


and in globalscript.ash:

import function SayLetterByLetter(this Character*, String sentence);


and you can use it from the rooms script;

cEgo.SayLetterByLetter("This is the first sentence");
Title: Re: Letter by letter msg display, Does it possible ?
Post by: NsMn on Sun 27/09/2009 12:33:47
Nope, it's not possible in General, you would have to make a costum GUI/function. Try this code:


//global script start

int Letterspeed;

function SayRPGGUI(this Character*,const string message){
String Text=message;
gRPGSpeech.Visible=true;
int for=1;
while(for<=Text.Length){
  lblRPGSpeech.Text=Text.Truncate(for);
  PlaySound(2);
  Wait(1);
  for=for+Letterspeed;
}
WaitKey(10000);
gRPGSpeech.Visible=false;
lblRPGSpeech.Text="";
}


Should work. Remember to declare the function and Letterspeed in the Global header, and to set Letterspeed in game_start (if it's 0, the game will crash because the loop will be repeated to many times).
Title: Re: Letter by letter msg display, Does it possible ?
Post by: Gumustdo on Sun 27/09/2009 13:03:57
Thank you very much, NsMn,tzachs. :D

I'll try them out.