displaying names from text actor

Game Editor comments and discussion.

displaying names from text actor

Postby mt » Mon Feb 12, 2007 7:37 am

is there a way to display more than one names from a file using a single text actor??
User avatar
mt
 
Posts: 34
Joined: Wed Dec 06, 2006 1:52 pm
Score: 2 Give a positive score

Postby Game A Gogo » Mon Feb 12, 2007 11:46 pm

it depends on what way you use to display the names, and what do you want exactly?
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby mt » Tue Feb 13, 2007 5:02 pm

there r 11 names in a file. can they be displayed by a single text actor using read from file functions?
User avatar
mt
 
Posts: 34
Joined: Wed Dec 06, 2006 1:52 pm
Score: 2 Give a positive score

Postby Game A Gogo » Wed Feb 14, 2007 12:23 am

sure, but, how is the test in the file sorted ,like? and how you want them to be displayed?
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby mt » Wed Feb 14, 2007 6:37 am

the names in text are wriiten like:

RickyPonting
Adam Gilchrist
blah blah

and we want to display the names exactly like that in a single text actor.
User avatar
mt
 
Posts: 34
Joined: Wed Dec 06, 2006 1:52 pm
Score: 2 Give a positive score

Postby DilloDude » Wed Feb 14, 2007 7:22 am

Either go through the file with fgetc and get each individual character and add it to a string, or use fgets to get each line, add it to a temp string and add a newline character before adding the next line.
http://game-editor.com/docs/script_reference.htm#fgetc
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby mt » Wed Feb 14, 2007 5:35 pm

oh ok im reading from the file and i put all the names in an astructure like this
struct s{
char name[20];
}readname[11];

now all the 11 names from the file r in the readname[i].name
i can display 1 name by readname[0].name or readname[4].name by a text actor. but i want all the 11 names i put in this struct to show in a single text actor. is there any way to do that?
User avatar
mt
 
Posts: 34
Joined: Wed Dec 06, 2006 1:52 pm
Score: 2 Give a positive score

Postby DilloDude » Thu Feb 15, 2007 3:18 am

Try something like this:
Code: Select all
sprintf(text, "%s\n%s\n%s\n%s", readname[0].name, readname[1].name, readname[2].name, readname[3].name);

Add more as required. The %s inserts a string variable (specified by the latter variable(s)), the \n is a newline character. You could also use lots of strcat() functions, but with sprintf, you only need to have one line.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron