Page 1 of 1
displaying names from text actor

Posted:
Mon Feb 12, 2007 7:37 am
by mt
is there a way to display more than one names from a file using a single text actor??

Posted:
Mon Feb 12, 2007 11:46 pm
by Game A Gogo
it depends on what way you use to display the names, and what do you want exactly?

Posted:
Tue Feb 13, 2007 5:02 pm
by mt
there r 11 names in a file. can they be displayed by a single text actor using read from file functions?

Posted:
Wed Feb 14, 2007 12:23 am
by Game A Gogo
sure, but, how is the test in the file sorted ,like? and how you want them to be displayed?

Posted:
Wed Feb 14, 2007 6:37 am
by mt
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.

Posted:
Wed Feb 14, 2007 7:22 am
by DilloDude
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

Posted:
Wed Feb 14, 2007 5:35 pm
by mt
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?

Posted:
Thu Feb 15, 2007 3:18 am
by DilloDude
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.