How to use a string Entered through a textbox, throughout the game??

Started by Timosity, Tue 20/05/2003 18:14:22

Previous topic - Next topic

Timosity

I've been messing around with this for hours and can't figure it out or find any help.

I have a gui where you can type in  anything you like.

but i need it to be able to be use what is entered throughout the game.


What I have tried is first put

string input;

at the very start of the global script


then in "the function interface_click(int interface, int button)"

"in my tenth gui i have a text box"



if (interface == 10){

 if (button == 0)
     
     GetTextBoxText (10,0,input);
     GUIOff(10);
     GUIOn(1);
     
 
 
 
 }


I want to use the input string throughout the game but it doesn't recognise "input" in the room scripts.

I figure I need to use a global string

but how do you get that to work in a "Display" command

I know you write

Display("%s la di da di da", input);

but if you use a global string, I can't figure out how you script it.


I'm sure someone knows

Am I on the right track?

thanks

Scorpiorus

If you use a global string then you need to declare a buffer string to retrieve it's value:

string input;

if (interface == 10){

if (button == 0)
 
  GetTextBoxText (10,0,input);
  SetGlobalString (1, input); //set up global string

  GUIOff(10);
  GUIOn(1);
 
}


then in some room:

string buf_string;
GetGlobalString (1, buf_string);  //retrieve data from global string
Display("%s la di da di da", buf_string); //display the data


Although you can do it this way I only showed here how to use global strings. Actually you do not need to use GlobalStrings at all.
The best way to do is to retrieve the TextBoxText when you need. Actually you can call GetTextBoxText() from any room script so just use it: :)


room function:

string buf_string;
GetTextBoxText (10,0, buf_string);
Display("%s la di da di da", buf_string);

hope it helps

[EDIT]
but if you want the string to represent some general data like character nickname/profession/.... etc. or as I see you want to use it later then the using of global string is more preferable of course.

-Cheers

Timosity

Thanks Scorpiorus,

It works perfectly, I went with the global string seeing as it won't be used just in 1 room.

I tried something almost Identical but I used SetGlobalString rather than GetGlobalString

Appreciated muchly

SMF spam blocked by CleanTalk