Understanding the TypeLine function. (SOLVED)

Started by Mugs, Fri 17/03/2006 03:58:55

Previous topic - Next topic

Mugs

Alright,

I do not know how to use the typeline function, at all.Ã,  I am displaying text using a label inside of a GUI, like so:


textlabel.SetText("This is called text!");


Can anyone tell me what to do in order make a simple typewriting effect.

P.S. I've seen the original Typeline function before.


Cool stuff I found out: Men are four times more likely to be struck by lightning than women.  Wow, really? [dirty joke] Maybe this has to do with the fact that us men have "lightning rods"? [/dirty joke]

Khris

You mean this function?

Remove
Code: ags
textid = CreateTextOverlay(xpos,50,400,font,colour,displayedline);


Replace
Code: ags
SetTextOverlay(textid, 10,vspacing,400, font, colour, displayedline);
with
Code: ags
textlabel.SetText(displayedline);


Then, instead of calling
Code: ags
textlabel.SetText("This is called text!");
call
Code: ags
TypeLine("This is called text!", 0);

Mugs

Thanks again, KhrisMUC

:-X Now let's test it...

??? Damn...

:( Error (line 10): Type mismatch: cannot convert 'const string' to 'string'

Any solutions?
Cool stuff I found out: Men are four times more likely to be struck by lightning than women.  Wow, really? [dirty joke] Maybe this has to do with the fact that us men have "lightning rods"? [/dirty joke]

Khris

Try

function TypeLine(const string line) {
...
}

(vspacing isn't needed anymore)

Mugs

Alright, I got rid of that problem.

But now I get this:

in Global Script
Error (line 13) type 'string' is no longer supported; use 'String' instead.

I know I can't just replace the letter 's' for an 'S'. That would give me:

Type mismatch: cannot convert 'String' to 'string'
Cool stuff I found out: Men are four times more likely to be struck by lightning than women.  Wow, really? [dirty joke] Maybe this has to do with the fact that us men have "lightning rods"? [/dirty joke]

Gilbert

Uncheck 'enforce new string' or something in the editor.

Though the best solution is to rewrite the functions...

Mugs

#6
This is what I have:

Code: ags

function TypeLine(const string line) {

Ã,  
Ã,  int length=0;
Ã,  int i = 0;
Ã,  string displayedline_new;
Ã,  string displayedline_old;

Ã,  int textid = 0;

Ã,  length = 0;Ã,  
Ã,  i=0; 
Ã,  StrCopy(displayedline_old," ");
Ã,  length=StrLen(line); //set string length
Ã,  while(i<length){
Ã,  Ã,  StrCopy(displayedline_new, displayedline_old);
Ã,  Ã,  StrFormat(displayedline_new, "%s%c", displayedline_old, StrGetCharAt(line,i)); 
Ã,  Ã,  i++;
Ã,  Ã,  text.SetText(displayedline_new);
Ã,  Ã,  PlaySound(1);
Ã,  Ã,  Wait(5);
Ã,  }
Ã,  return textid;
} 


The game types each letter one by one,Ã,  but they type on top of eachother, which means, only one letter appears at a time.

What did I do wrong?
Cool stuff I found out: Men are four times more likely to be struck by lightning than women.  Wow, really? [dirty joke] Maybe this has to do with the fact that us men have "lightning rods"? [/dirty joke]

Khris

Try this:

Code: ags
function TypeLine(String line) {

Ã,  int length=line.Length;
Ã,  int i = 0;
Ã,  String displayedline="";

Ã,  while(i<length){
Ã,  Ã,  displayedline.AppendChar(line.Chars[i]);
Ã,  Ã,  text.SetText(displayedline);
Ã,  Ã,  PlaySound(1);
Ã,  Ã,  Wait(5);
Ã,  Ã,  i++;
Ã,  }
}

Mugs

I can hear sound, but I can't see the text.
Cool stuff I found out: Men are four times more likely to be struck by lightning than women.  Wow, really? [dirty joke] Maybe this has to do with the fact that us men have "lightning rods"? [/dirty joke]

Mugs

#9
I've been looking at the script for a while.Ã,  I tried adding and modifing things,Ã,  and nothing works.Ã,  Ã,  What's wrong with the script?

EDIT: I double posted by accident, sorry.
Cool stuff I found out: Men are four times more likely to be struck by lightning than women.  Wow, really? [dirty joke] Maybe this has to do with the fact that us men have "lightning rods"? [/dirty joke]

Khris

After wondering what's wrong with it for hours, it suddenly came to me:
Code: ags
displayedline=displayedline.AppendChar(line.Chars[i]);


QuoteNOTE: The new concatenated string is returned as a new string from this function; it does NOT modify the original string.

Mugs

 :D It works!!!Ã,  I can finally relax!Ã,  Ã, 


Thank you for helping me with this problem (and other problems in other threads :P)

Cool stuff I found out: Men are four times more likely to be struck by lightning than women.  Wow, really? [dirty joke] Maybe this has to do with the fact that us men have "lightning rods"? [/dirty joke]

SMF spam blocked by CleanTalk