pausing script with custom InputBox

Started by Goldmund, Sat 28/06/2008 00:39:11

Previous topic - Next topic

Goldmund

Hello.

I don't know if it's a "beginners question" or not, but it sure drives me into black desperation.

I want to have my own custom GUI that will work like the default InputBox does.
So, I made a GUI ("gInputBox") with a textbox called "InBox", it's set to PopupModal and everything.

Let's say that player clicks on his/her Bible of Satan.
Such script is then executed in the inventory interaction:

Display("What are we searching for?")
gInputBox.Visible = true;
string answer;
Display("Alas! Your search for %s is in vain", answer);

As it is now, when you click on your Bible, the game immediately displays the GUI and "Alas! Your search etc." without waiting for the player's text input.

The script doesn't wait for the player to type anything in the text box.

Unlike the default InputBox.

I could put all that in the textbox's "On Activate", but:

1) It's a terrible work, as my game uses plenty of "Input boxes" and I would like to keep the respective scripts in the rooms where the gInputBox is called;

2) Plenty of reactions to the player's text input deal with objects and other stuff that CANNOT be run from the global script.

How can I pause the local script when the gInputBox is displayed and then continue it when the player types something??...

Help!

Ishmael

You could create a global string, set the string to the value of the textbox in it's On Activate after the GUI.Visible command, then wait until the string is not empty. Or alternatively just wait until the GUI is turned off.

But unfortunately I don't remember off the top of my head how to make a local, non-blocking wait like that...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Khris

You can put CallRoomScript(1); at the end of _OnActivate(), then process the global answer string in the room's on_call():

Tested and working example:
Code: ags
// header
import String answer;
import function Query();

// global script
String answer;
export answer;

function Query() {
  field.Text = "";
  gInputBox.Visible = true;
}

function field_OnActivate(GUIControl *control) {
  answer = field.Text;
  gInputBox.Visible = false;
  CallRoomScript(1);
}

// room 1
function on_key_press(int k) {
  if (k == 'Q') {
    Display("Please enter a query!");
    Query();
  }
}

function on_call(int p) {
  if (p == 1) Display("Your query is: '%s'", answer);
}

Goldmund

Yes, the CallRoomScript works!

And it's a much easier solution that checking for global ints in rep_ex. :-)

Thank you!

SMF spam blocked by CleanTalk