Page 1 of 1

how do i load a text file?

PostPosted: Sat Feb 16, 2008 4:39 pm
by DarkParadox
i need a code that will load a .txt file according to a text actor's text
now all i need is the code above

Re: Rename text problem/Load File

PostPosted: Sat Feb 16, 2008 6:51 pm
by Azou
I have just one solution:
Make the txt to be an animation
An then
Key down--Your key---Change animation/Txt into txt 2
Is it that,Diormeh? :D

Re: Rename text problem/Load File

PostPosted: Sat Feb 16, 2008 9:02 pm
by DarkParadox
no, it isn't.
i wanted it to go on forever and it HAS to be a text actor

Re: Rename text problem/Load File

PostPosted: Sat Feb 16, 2008 9:18 pm
by pyrometal
Here it is!

Demo.zip
(196.24 KiB) Downloaded 149 times


I don't know how to read and write files successfully yet so I'll leave that part to someone else.

Re: Rename text problem/Load File

PostPosted: Sat Feb 16, 2008 9:26 pm
by DarkParadox
Thanks! :D
but i still need the load function

Re: how do i load a text file?

PostPosted: Sun Feb 17, 2008 11:43 am
by makslane

Re: how do i load a text file?

PostPosted: Sun Feb 17, 2008 10:40 pm
by makslane
To put the whole text in a single actor text, you can use:

Code: Select all
void readtext(char *fileName, char *s)
{
    int c;
    FILE *fp = fopen(fileName, "r");
    if(fp)
    { 
      while((c = fgetc(fp)) >= 0) *s++ = c;
      fclose(fp);
    }

    *s = 0;
}


And call in some action:

Code: Select all
readLines("myfile.txt", mytextactor.text);


The file must exists in the same folder of the game.

Re: how do i load a text file?

PostPosted: Sun Feb 17, 2008 11:26 pm
by DarkParadox
makslane......
theres a problem with that code too,
it gets rid of the first line....