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.
You mean this function (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=14437.0)?
Removetextid = CreateTextOverlay(xpos,50,400,font,colour,displayedline);
ReplaceSetTextOverlay(textid, 10,vspacing,400, font, colour, displayedline);
withtextlabel.SetText(displayedline);
Then, instead of callingtextlabel.SetText("This is called text!");
callTypeLine("This is called text!", 0);
Thanks again, KhrisMUC
:-X Now let's test it...
??? Damn...
:( Error (line 10): Type mismatch: cannot convert 'const string' to 'string'
Any solutions?
Try
function TypeLine(const string line) {
...
}
(vspacing isn't needed anymore)
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'
Uncheck 'enforce new string' or something in the editor.
Though the best solution is to rewrite the functions...
This is what I have:
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?
Try this:
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++;
Ã, }
}
I can hear sound, but I can't see the text.
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.
After wondering what's wrong with it for hours, it suddenly came to me:
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.
:D It works!!!Ã, I can finally relax!Ã, Ã,Â
Thank you for helping me with this problem (and other problems in other threads :P)