NEED HELP PLEASE!!!

Game Editor comments and discussion.

NEED HELP PLEASE!!!

Postby tarice » Thu Apr 23, 2009 8:53 pm

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.
tarice
 
Posts: 19
Joined: Fri Jan 16, 2009 7:25 pm
Score: 0 Give a positive score

Re: NEED HELP PLEASE!!!

Postby DarkParadox » Thu Apr 23, 2009 9:01 pm

Code: Select all
sprintf(string, "%d", var);

if you need more of an explanation, I'd be happy to give it :3
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: NEED HELP PLEASE!!!

Postby tarice » Thu Apr 23, 2009 9:10 pm

You Rock!! thanks!!
tarice
 
Posts: 19
Joined: Fri Jan 16, 2009 7:25 pm
Score: 0 Give a positive score

Re: NEED HELP PLEASE!!!

Postby tarice » Thu Apr 23, 2009 9:14 pm

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.
tarice
 
Posts: 19
Joined: Fri Jan 16, 2009 7:25 pm
Score: 0 Give a positive score

Re: NEED HELP PLEASE!!!

Postby skydereign » Fri Apr 24, 2009 2:02 am

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);
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: NEED HELP PLEASE!!!

Postby tarice » Fri Apr 24, 2009 11:39 am

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?
tarice
 
Posts: 19
Joined: Fri Jan 16, 2009 7:25 pm
Score: 0 Give a positive score

Re: NEED HELP PLEASE!!!

Postby skydereign » Fri Apr 24, 2009 6:15 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron