Change text problem

Non-platform specific questions.

Change text problem

Postby PWNED » Fri Dec 03, 2010 8:47 pm

Hey Everyone!
I need help with one of the lines of code, How do you change the text of a text Actor?
Iv'e been experimenting but I can't seem to find out how to do it could you please help?
PWNED
 
Posts: 16
Joined: Wed Jul 21, 2010 10:17 pm
Score: 0 Give a positive score

Re: Change text problem

Postby Hblade » Fri Dec 03, 2010 9:48 pm

yeah :D

sprintf(text, "Your text here");

You can also display numbers of variables too, like this for example:
sprintf(text, "Yo :D Your age is %d, your name is %s", AGE, TEXT_VARIABLE);

where AGE and TEXT_VARIABLE are variables :D

%d tells integer like values and %s does string :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Change text problem

Postby PWNED » Sat Dec 04, 2010 2:33 am

Hblade wrote:yeah :D

sprintf(text, "Your text here");

You can also display numbers of variables too, like this for example:
sprintf(text, "Yo :D Your age is %d, your name is %s", AGE, TEXT_VARIABLE);

where AGE and TEXT_VARIABLE are variables :D

%d tells integer like values and %s does string :D


hmm tried that but all it did was make game-editor crash multiple times...
Code: Select all
if(Universe_ = 0);
{
    sprintf("Then the universe was created.");
    Universe_ = 1;
}

this is with Universe_ as a Var. what am I doing wrong?
PWNED
 
Posts: 16
Joined: Wed Jul 21, 2010 10:17 pm
Score: 0 Give a positive score

Re: Change text problem

Postby DarkParadox » Sat Dec 04, 2010 2:49 am

Using the = sign means assigning a value to a variable. When comparing values we need to use ==, not =.
Along with that, sprintf needs a variable to assign the text to, I assume we're using the current actors text, so we use the variable text.
So, when it's all fixed up, it ends up like this Image
Code: Select all
if(Universe_ == 0);
{
    sprintf(text, "Then the universe was created.");
    Universe_ = 1;
}

Hope this helps Image
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Change text problem

Postby PWNED » Sat Dec 04, 2010 2:55 am

DarkParadox wrote:Using the = sign means assigning a value to a variable. When comparing values we need to use ==, not =.
Along with that, sprintf needs a variable to assign the text to, I assume we're using the current actors text, so we use the variable text.
So, when it's all fixed up, it ends up like this Image
Code: Select all
if(Universe_ == 0);
{
    sprintf(text, "Then the universe was created.");
    Universe_ = 1;
}

Hope this helps Image

Ya that helps alot thx!!
PWNED
 
Posts: 16
Joined: Wed Jul 21, 2010 10:17 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest