Page 1 of 1

A easy way to do monolog~

PostPosted: Tue Sep 01, 2009 4:24 am
by cforall
This is a part of my new demo...I write these codes in a clear style.
You could easily add million messages if you want~ :D :D
Oh~remember using escape characters like "\n" ...



Add a Normal Actor Texts.
Create a Global/Actor int var WordCount.

Texts -> Create Actor:
Code: Select all
strncpy(text,"",256);

WordCount = 1;

CreateTimer("Event Actor", "ControlTexts", 100); //10 Letters per second.

Texts -> Timer(ControlTexts):
Code: Select all
int str0_lw = 0;

//Define Message1
char *str1 = "Samoa is an ideal location for Survivor.";
int str1_l = strlen(str1);
int str1_lw = str1_l*2 + str0_lw; //About the multiplication: If your message have 10 letters, wipe it after another 10 letters time.

//Define Message2
char *str2 = "There are lots of remote beaches and jungles to choose from.";
int str2_l = strlen(str2);
int str2_lw = str2_l*2 + str1_lw;

//Define Message3
char *str3 = "The most likely spot would probably be chosen on the island of Savaii.";
int str3_l = strlen(str3);
int str3_lw = str3_l*2 + str2_lw;

//Show Message1
if(WordCount > str0_lw && WordCount <= str0_lw + str1_l)
{
   strncpy(text,str1,WordCount - str0_lw);
   WordCount++;
}
else if(WordCount > str0_lw + str1_l && WordCount <= str1_lw)
{   
   if(WordCount == str1_lw) strncpy(text, "", 256);
   WordCount++;
}     

//Show Message2
else if(WordCount > str1_lw && WordCount <= str1_lw + str2_l)
{
   strncpy(text,str2,WordCount - str1_lw);
   WordCount++;
}
else if(WordCount > str1_lw + str2_l && WordCount <= str2_lw)
{
   if(WordCount == str2_lw) strncpy(text, "", 256);
   WordCount++;
}

//Show Message3
else if(WordCount > str2_lw && WordCount <= str2_lw + str3_l)
{
   strncpy(text,str3,WordCount - str2_lw);
   WordCount++;
}
else if(WordCount > str2_lw + str3_l && WordCount <= str3_lw)
{
   if(WordCount == str3_lw) strncpy(text, "", 256);
   WordCount++;
}


If you want change speed temporarily, you could insert code like:
Code: Select all
if(WordCount == strX_lw + XX)
  DestroyTimer("ControlTexts"),
  CreateTimer("Event Actor", "ControlTexts", XXX);

Re: A easy way to do monolog~

PostPosted: Tue Sep 01, 2009 4:26 am
by Hblade
Hey sweet, thats awesome