Page 1 of 1

In Game Text

PostPosted: Tue May 11, 2010 3:15 am
by GuybrushThreepwood
Is there a way to change the text of a text actor without making a new actor? And also, how can you make the game choose a certain line of text at random from a whole list of pre-made texts every time you press a button? If anyone could help, it would be greatly appreciated :mrgreen:

Re: In Game Text

PostPosted: Tue May 11, 2010 11:47 am
by Hblade
There's many ways ^.^

1, is to use the set text command (without coding) 2 is coding You can use t he following :3
Code: Select all
sprintf(text, "Text here");

In sprintf you can also call the ammounts of variables by doing this
Code: Select all
sprintf(text, "Hello %d %s %i", x, text_variable, integer);

Replace x, text_var, and integer with the names of the variables your using. %d calls uh... just like %i really, it gives you the value of the variable.

%s gives you the value of a text variable so if you hav e your player customizable name, %s will call his name after the word "Hello" according to the sprintf command :D



The other commands you can use are:
    strcpy
    strcat
strcpy is used just like sprintf, but I'm not sure if strcpy can use the %d, s, and i and stuff like that.
strcat appends text to the current text you already have. For example if your text says "Hello", use
Code: Select all
strcat(text, "My name is bob");

And then it'll say "Hello my name is bob".

Hope this helped :D

Re: In Game Text

PostPosted: Tue May 11, 2010 9:23 pm
by GuybrushThreepwood
I'm uh... not really good at scripting, so I barely know what your talking about :oops:
I get the changing the text with the set text thing, but I don't get the picking the random line of text from like 40 different ones part. And also, I should have mentioned earlier, I want the used line of text to be destroyed after it's use. How would I do that?

Re: In Game Text

PostPosted: Tue May 11, 2010 9:32 pm
by Hblade
Not sure thats even possible, sorry :o

Re: In Game Text

PostPosted: Wed May 12, 2010 5:41 am
by GuybrushThreepwood
Well then how about just picking one of 5 texts at random>

Re: In Game Text

PostPosted: Wed May 12, 2010 11:30 am
by Hblade
I dont think GE supports selecting characters from a text actor yet. Perhaps in the new version, sorry :o

Re: In Game Text

PostPosted: Wed May 12, 2010 10:13 pm
by GuybrushThreepwood
Thats OK, thanks anyway :mrgreen:

EDIT: I maybe need to reword my question, I don't mean making up its own text, but randomly selecting a couple of text actor's I've already made and bringing them to a certain spot or something like that

Re: In Game Text

PostPosted: Thu May 13, 2010 1:21 pm
by Hblade
Oh I think I know what you mean :D Yeah use the MoveTo function for that ^.^