Page 1 of 1

NEED HELP PLEASE!!!

PostPosted: Thu Apr 23, 2009 8:53 pm
by tarice
I want to set a variable as a text for example. strcpy(random.text,variable); I need to convert a integer into text. please help.

Re: NEED HELP PLEASE!!!

PostPosted: Thu Apr 23, 2009 9:01 pm
by DarkParadox
Code: Select all
sprintf(string, "%d", var);

if you need more of an explanation, I'd be happy to give it :3

Re: NEED HELP PLEASE!!!

PostPosted: Thu Apr 23, 2009 9:10 pm
by tarice
You Rock!! thanks!!

Re: NEED HELP PLEASE!!!

PostPosted: Thu Apr 23, 2009 9:14 pm
by tarice
DarkParadox wrote:
Code: Select all
sprintf(string, "%d", var);

if you need more of an explanation, I'd be happy to give it :3

Yeah i'm kinda stuck can you give me a little more help.

Re: NEED HELP PLEASE!!!

PostPosted: Fri Apr 24, 2009 2:02 am
by skydereign
This prints a formatted string. String would be the text of your actor. Let's say your text actor is named random. The "%d" converts an int into the string. Since the sprintf is asking for only one int, the variable , var, is put into the string.
Code: Select all
sprintf(random.text, "%d", var);

Re: NEED HELP PLEASE!!!

PostPosted: Fri Apr 24, 2009 11:39 am
by tarice
skydereign wrote:This prints a formatted string. String would be the text of your actor. Let's say your text actor is named random. The "%d" converts an int into the string. Since the sprintf is asking for only one int, the variable , var, is put into the string.
Code: Select all
sprintf(random.text, "%d", var);

Yeah I already figured that out, but what if I want to use more than one variable?

Re: NEED HELP PLEASE!!!

PostPosted: Fri Apr 24, 2009 6:15 pm
by skydereign
Oh, I was just guessing what you needed help with, sorry. Just add more in the string. You can also add other types of variables.
Code: Select all
sprintf(random.text, "%d, %d", var1, var2);

This would set the text to
1, 2
Assuming var1=1 and var2=2.