Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Scrolling Text Request #422283
05/07/13 04:55
05/07/13 04:55
Joined: Oct 2010
Posts: 15
M
Minoterrae Offline OP
Newbie
Minoterrae  Offline OP
Newbie
M

Joined: Oct 2010
Posts: 15
I am looking for someone to write me a small script which will scroll text right-to-left strings read from a text file. It should work like a news/sports crawl on CNN or ESPN, etc.,

Some of the strings are quite long but most are 300 characters or less.

If you would like to do this for free, great. If you would like to be paid, give me a quote.

Re: Scrolling Text Request [Re: Minoterrae] #422286
05/07/13 08:53
05/07/13 08:53
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
use file_str_read to read your text from txt file :

Code:
#include <acknex.h>
#include <default.c>

STRING* texttest = "";
TEXT* mytext =
{
	string =texttest ;
	pos_y = 10;
	flags = SHOW;
}
function main ()
{
	var fhandle = file_open_read("my text.txt"); // test.txt contains "this,is,a,test"
	file_str_read(fhandle,texttest); // sTest now contains "this"
	file_close(fhandle);	
   fps_max = 60;
        mytext.pos_x =screen_size.x+10;
	while(1)
	{
		mytext.pos_x -=1;
		wait(1);
	}
	
}


Last edited by Dico; 05/07/13 08:55.
Re: Scrolling Text Request [Re: Dico] #422293
05/07/13 09:55
05/07/13 09:55
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I would edit Dico's example a bit laugh
Here it comes (thank you Dico):
Code:
// empty string:
STRING* texttest = "";

// text to be displayed:
TEXT* mytext = {
	// set the string:
	string = texttest;
	// set flags:
	flags = SHOW;
}

// main game funciton:
function main (){
	// open the text file:
	var fhandle = file_open_read("my.txt");
	// read it's content, and save it into the string:
	file_str_read(fhandle, texttest);
	// close the text file (make sure, you close it after opening):
	file_close(fhandle);
	// place text at the far right corner:
	mytext.pos_x = screen_size.x + 5;
	// wait one frame (I'm not sure yet, but without this it causes error):
	wait(1);
	// get the width of the string:
	var width = str_width(texttest, NULL);
	// loop:
	while(1){
		// if text if gone to the left corner:
		if(mytext.pos_x < -width){
			// set it back to the upper right corner:
			mytext.pos_x = screen_size.x + 5;
		}
		// scroll text to the left:
		mytext.pos_x -= 10 * time_step;
		// place text at the far right corner:
		mytext.pos_y = screen_size.y - 50;
                // wait one frame:
		wait(1);
	}	
}


I hope this helps! Good luck!

Edit: removed "200", cause that was causing problems with small text!!


Greets

Last edited by 3run; 05/07/13 12:29. Reason: FIXED BUG!

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Scrolling Text Request [Re: 3run] #422299
05/07/13 10:24
05/07/13 10:24
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
Originally Posted By: 3run
I would edit Dico's example a bit laugh
Here it comes (thank you Dico):
Code:
// empty string:
STRING* texttest = "";

// text to be displayed:
TEXT* mytext = {
	// set the string:
	string = texttest;
	// set flags:
	flags = SHOW;
}

// main game funciton:
function main (){
	// open the text file:
	var fhandle = file_open_read("my.txt");
	// read it's content, and save it into the string:
	file_str_read(fhandle, texttest);
	// close the text file (make sure, you close it after opening):
	file_close(fhandle);
	// place text at the far right corner:
	mytext.pos_x = screen_size.x + 5;
	// wait one frame (I'm not sure yet, but without this it causes error):
	wait(1);
	// get the width of the string:
	var width = str_width(texttest, NULL);
	// loop:
	while(1){
		// if text if gone to the left corner (play/remove 200 if needed):
		if(mytext.pos_x < -width + 200){
			// set it back to the upper right corner:
			mytext.pos_x = screen_size.x + 5;
		}
		// scroll text to the left:
		mytext.pos_x -= 10 * time_step;
		// place text at the far right corner:
		mytext.pos_y = screen_size.y - 50;
                // wait one frame:
		wait(1);
	}	
}


I hope this helps! Good luck!


Greets


you're the best wink

Re: Scrolling Text Request [Re: Dico] #422301
05/07/13 10:33
05/07/13 10:33
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: Dico
you're the best wink
The source is yours, so you are still the best wink


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Scrolling Text Request [Re: 3run] #422314
05/07/13 12:29
05/07/13 12:29
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: Scrolling Text Request [Re: sivan] #422315
05/07/13 12:30
05/07/13 12:30
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
sivan@ grin


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Scrolling Text Request [Re: 3run] #422323
05/07/13 14:54
05/07/13 14:54
Joined: Oct 2010
Posts: 15
M
Minoterrae Offline OP
Newbie
Minoterrae  Offline OP
Newbie
M

Joined: Oct 2010
Posts: 15
Thanks, guys. I appreciate it a lot.

Re: Scrolling Text Request [Re: Minoterrae] #422330
05/07/13 15:57
05/07/13 15:57
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
sivan@ is this u in the pic hahaha


Moderated by  adoado, checkbutton, mk_1, Perro 

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