Page 1 of 1

all about text

PostPosted: Fri Nov 26, 2010 4:35 am
by 157pl
i want to know how to use the "text" in script editor. can it only be used to put into things like openUrl(text); or can you use it to input words into an actors text like a cin function in a regular c++ compiler?
if not how can you?

Re: all about text

PostPosted: Fri Nov 26, 2010 8:31 am
by skydereign
The text variable is a string. You can use most string functions to manipulate/use it. There are two ways to get input into a text actor, first by using the built in text input system. To turn it on for your text actor, click on the text button in the actor control panel. At the bottom left, there is a Text Input: [No], switch that to yes. With config you can edit the settings.

The other is to use the str functions on keydown event to edit the text variable. If you would like examples or further explanation just ask.

Re: all about text

PostPosted: Fri Nov 26, 2010 3:35 pm
by 157pl
thank you but is there a way you could use it in an if statement ?
like to see if the text is icecream or not

Re: all about text

PostPosted: Fri Nov 26, 2010 3:54 pm
by 157pl
i also need to input text in the script editor how would i do that
i need to do something like
text2.text=text1.text;
or something like that

Re: all about text

PostPosted: Fri Nov 26, 2010 5:54 pm
by lcl
For checking if the string is same as something, use strcmp();
This way:
Code: Select all
if (strcmp(text, "icecream") == 0)
{
Here comes the action.
}

For copying strings use strcpy();
Code: Select all
strcpy(Text2.text, Text1.text);

:D

Re: all about text

PostPosted: Sat Nov 27, 2010 5:45 am
by 157pl
ok thanks im almast done i just need to know how to save and load text into an actor...

Re: all about text

PostPosted: Sat Nov 27, 2010 8:16 am
by skydereign
If you mean saving a variable, so you can reload it when you play the game again, then you'll need to use the saveVars function or save the string in a text file. Either way you'll need a string variable, which can be used to access the text you want. Here's an example.

Create a string variable saveText, and put it into the a Save Group (like savefile).

To copy the text into the string saveText, use this.
Code: Select all
strcpy(saveText,actor.text);


To save the variable you'll need to save the save group you put saveText in.
Code: Select all
saveVars("savefile", "savefile");


Now when you want to load the string into a text actor, you can use this.
Code: Select all
loadVars("safefile", "safefile");
strcpy(actor.text, saveText);