Page 1 of 1

Change text problem

PostPosted: Fri Dec 03, 2010 8:47 pm
by PWNED
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?

Re: Change text problem

PostPosted: Fri Dec 03, 2010 9:48 pm
by Hblade
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

Re: Change text problem

PostPosted: Sat Dec 04, 2010 2:33 am
by PWNED
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?

Re: Change text problem

PostPosted: Sat Dec 04, 2010 2:49 am
by DarkParadox
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

Re: Change text problem

PostPosted: Sat Dec 04, 2010 2:55 am
by PWNED
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!!