Page 1 of 1

line copy function, allows you to copy a selected line....

PostPosted: Tue Jun 12, 2007 12:14 am
by Sgt. Sparky
here is a line copy function, allows you to copy a selected line from a selected actors text,
to use this, put this code in global code:
Code: Select all
void linecopy(int b, char a[255])
{
int i, line_pos, i2, Num;
line_pos = 0;
i2 = 0;
Num = 0;
i = 0;
strcpy(text, "");
for(i = 0; i <= strlen(a); i++)
{
    if(line_pos == b - 1)Num = i;
    if(strncmp(&a[i], "\n", 1) == 0)line_pos++;
    if(line_pos == b)i2 = i;
}
i = Num;
for(i = Num; i <= i2; i++)
{
    strncpy(temp, &a[i], 1);
    strcat(text, temp);
}
}

now for copying after you add this to global code put this on any event for a text actor,
linecopy(theline, soandso.text);
or to do this litterally:
if I want to copy line 5 from an actor called myactor,
linecopy(4, myactor.text);
remember, 0 is the first line, 1 is the second, and so on. :D
you can also copy from varables, like a variable called myvar, that is string, and global on line 5,
linecopy(4, myvar);
it is just like using strcpy. :D