|
2 registered members (juanex, AndrewAMD),
988
guests, and 8
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Complicated String Question
#372953
06/06/11 04:25
06/06/11 04:25
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
Okay. So I haven't been on the forum in a while. I Haven't really had any time to program - However, in my spare time I have been programming a game with C-script. So, I'm gunna stop beating around the bush - .......................... I am trying to program it so that my text slowly appears on-screen, rather than all at once. But I have run into a small problem.. I can't figure out what to do next.. I've fought with this for hours on end, and can't seem to get it to work.
....
str_cpy(temp_str, sign0001);//Copy the signs text to a temp string
text_characters = str_len(temp_str);//get the length of the "temp string"
text_concealer = text_characters;//the concealer's length is now the length of the 'temp str'
str_trunc(temp_str, text_concealer);
thesign_txt.visible = on;//wait till all the mumbo jumbo is done before showing the text
while(text_concealer>0){wait(-0.5);
//This should slowly show the text again.. but it doesn't.
str_trunc(temp_str, text_concealer);
text_concealer -= 1;
}
What is it that I need to do, to make this work? I've played with different options, but still no result. Any professional opinions?
|
|
|
Re: Complicated String Question
[Re: DLively]
#372955
06/06/11 04:55
06/06/11 04:55
|
Joined: May 2009
Posts: 1,816 at my pc (duh)
darkinferno
Serious User
|
Serious User
Joined: May 2009
Posts: 1,816
at my pc (duh)
|
i take it youre trying to show the string letter by letter ? str_trunc(temp_str, text_concealer); this line looks suspicious, wouldnt this line clear the entire string ? i think u may need a third display string, you need one that permanently holds the message, one that youre applying changes to, and another that youre displaying, if youre trying to display the one youre applying changes to, you'll get flickering in the onscreen message i think i would:
while(text_concealer>0){wait(-0.5);
str_trunc(temp_str,text_concealer);
str_cpy(displayString,temp_str); // update display string
str_cpy(temp_str, sign0001);
text_concealer -= 1;
ofcourse if i'm wrong someone will correct me, 11:54pm so brain asleep 
|
|
|
Re: Complicated String Question
[Re: DLively]
#372957
06/06/11 05:53
06/06/11 05:53
|
chris_oat
Unregistered
|
chris_oat
Unregistered
|
if you mean a type-writer text like in the old Resident Evil games, i can totaly help you out. I have a fully working c-script for that at home, that will write text on the screen, letter by letter. If you can hang on, i will post it later.
|
|
|
Re: Complicated String Question
[Re: DLively]
#373028
06/06/11 21:37
06/06/11 21:37
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
GOT IT XD Thanks Darkinferno!! Your code worked properly  I just needed sleep XD
|
|
|
Re: Complicated String Question
[Re: DLively]
#373373
06/09/11 18:50
06/09/11 18:50
|
chris_oat
Unregistered
|
chris_oat
Unregistered
|
i know im way too late, but it took me long to find the code because i had it on an old HDD. Anyway if you wanna see another typewriter code, here it goes:
string getFileNum;
string displayText;
string typewriterText;
function displayTextFromFile(file, number, textSpeed)
{
var fhandle;
fhandle = file_open_read(file);
// get number from the file
str_cpy(getFileNum, str_for_num(NULL, number));
str_cat(getFileNum, ": ");
file_find(fhandle, getFileNum);
file_str_read(fhandle, displayText);
file_close(fhandle);
var cutLength;
var stringLength;
stringLength = str_len(displayText);
cutLength = stringLength;
draw_textmode("Another Typewriter", 0, 38, 100); // set font
// get position to place at middle
var stringWidth;
stringWidth = str_len(displayText) * (38/2);
var stringPosX; stringPosX = (screen_size.x / 2) - (stringWidth / 2);
var stringPosY; stringPosY = (screen_size.y * 0.90) - (38 / 2);
while(1) {
// check to see if it's a question, and allow this to break from key Y and N too
if(key_y || key_n) {
if(my){
if(my.FLAG1 == 1) { break; }
}
}
if(key_space) {
if(my) {
if(my.FLAG1 == 0) {
break;
}
} else {
break;
}
}
cutLength -= textSpeed;
cutLength = clamp(cutLength, 0, stringLength);
str_cpy(typewriterText, displayText); // copy's file back again
str_trunc(typewriterText, cutLength); // remove letters, to simulate typewriter effect
draw_text(typewriterText, stringPosX, stringPosY, vector(255,255,255)); // draw text
wait(1);
}
}
It reads the text out of a txt.file. Code originaly written by helghast!
|
|
|
|