all about text

Game Editor comments and discussion.

all about text

Postby 157pl » Fri Nov 26, 2010 4:35 am

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?
User avatar
157pl
 
Posts: 109
Joined: Thu May 13, 2010 10:49 pm
Location: AZ
Score: 3 Give a positive score

Re: all about text

Postby skydereign » Fri Nov 26, 2010 8:31 am

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

Re: all about text

Postby 157pl » Fri Nov 26, 2010 3:35 pm

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
User avatar
157pl
 
Posts: 109
Joined: Thu May 13, 2010 10:49 pm
Location: AZ
Score: 3 Give a positive score

Re: all about text

Postby 157pl » Fri Nov 26, 2010 3:54 pm

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
User avatar
157pl
 
Posts: 109
Joined: Thu May 13, 2010 10:49 pm
Location: AZ
Score: 3 Give a positive score

Re: all about text

Postby lcl » Fri Nov 26, 2010 5:54 pm

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
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: all about text

Postby 157pl » Sat Nov 27, 2010 5:45 am

ok thanks im almast done i just need to know how to save and load text into an actor...
User avatar
157pl
 
Posts: 109
Joined: Thu May 13, 2010 10:49 pm
Location: AZ
Score: 3 Give a positive score

Re: all about text

Postby skydereign » Sat Nov 27, 2010 8:16 am

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);
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