Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
2 registered members (juanex, AndrewAMD), 988 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Complicated String Question #372953
06/06/11 04:25
06/06/11 04:25
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline 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.

Code:
....
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?


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
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 Offline
Serious User
darkinferno  Offline
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:

Code:
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 grin

Re: Complicated String Question [Re: DLively] #372957
06/06/11 05:53
06/06/11 05:53

C
chris_oat
Unregistered
chris_oat
Unregistered
C



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: ] #372978
06/06/11 12:55
06/06/11 12:55
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Thanks for your quick reply Darkinferno. I tried your solution last night with no result.. maybe I'm not doing it right, or maybe I was just too tired. Ill try it again when I get home from work.

Hey Chris_Oat, that would be great - I could really use someones finished version, and see how its done to apply it to my own work.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
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 Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
GOT IT XD


Thanks Darkinferno!! Your code worked properly tongue I just needed sleep XD


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: Complicated String Question [Re: DLively] #373373
06/09/11 18:50
06/09/11 18:50

C
chris_oat
Unregistered
chris_oat
Unregistered
C



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:
Code:
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!


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1