Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: rsja on Mon 23/11/2009 13:28:39

Title: Question to the user while playing
Post by: rsja on Mon 23/11/2009 13:28:39
Hello,

I would like for instance in a custscene to give a question to the user. I would like to ask them which room they would like to go to.


function room_AfterFadeIn()
{

  Overlay *textOverlay;
  textOverlay = Overlay.CreateTextual(320, 100, 200, eFontAriel, 1,  "test test.");
  Wait(140);
 

  //Here i would like something like that:

Wich room do you want to go to?

If he presses option 1:
player.ChangeRoom(3);

Of he presses option 2:
player.ChangeRoom(4);

}

Title: Re: Question to the user while playing
Post by: NsMn on Mon 23/11/2009 13:38:00
You can use a GUI with a textbox, but the Input function is much easier.


String GoToRoom=InputBox("Where would you like to go?");
player.ChangeRoom(GoToRoom.AsInt);


Look up InputBox in the manual to get more information.
Title: Re: Question to the user while playing
Post by: Akatosh on Mon 23/11/2009 13:49:49
Note that NsMn's code only works if the user is asked and inputs a number, however, and allows the player to access any room by inputting the correct one... the InputBox function is a quick and simple way to do this, but you'll need slightly more sophisticated scripting.

/EDIT:

String GoTo;
while ((GoTo.LowerCase()!="attic")&&(GoTo.LowerCase()!="bedroom")) GoToRoom=Game.InputBox("Where would you like to go - attic or bedroom?");
if (GoTo.LowerCase()=="attic") player.ChangeRoom(4);
else player.ChangeRoom(5);


Would be a quick'n'dirty, but HOPEFULLY workable example.
Title: Re: Question to the user while playing
Post by: Khris on Mon 23/11/2009 14:43:07
Isn't the question more about a two button GUI?

Create a GUI, set it to "pause game when shown", then add two buttons and double click them to make AGS create their OnClick functions. Put the ChangeRoom commands in those.
Title: Re: Question to the user while playing
Post by: NsMn on Mon 23/11/2009 14:47:05
If it's that what you want, I recommend using the DialogBox module (by SSH I believe)
Since having normal GUIs for this needs scripts in the rep_execute function, which isn't easy for a beginner.It doesn't just pause until the player makes his choice and then goes on with the cutscene script.
Title: Re: Question to the user while playing
Post by: Khris on Mon 23/11/2009 16:26:21
Quote from: NsMn on Mon 23/11/2009 14:47:05It doesn't just pause until the player makes his choice and then goes on with the cutscene script.

It doesn't? But that's exactly how that type of GUI (formerly called "PopUp") works; it pauses the game until it is turned not visible again.
Also I imagine if the player will go to a different room immediately afterwards, one would put gRoomChoice.Visible = true; at the end of the function, so even if having a GUI pop up would somehow not work during a cutscene (which it will just fine), there's not much cutscene left after it, at least not in that room.
Title: Re: Question to the user while playing
Post by: NsMn on Mon 23/11/2009 16:31:11
It pauses the GAME, not the running SCRIPT. So it's better to use the module for this case.

You don't know everything better Khris.
Title: Re: Question to the user while playing
Post by: Khris on Mon 23/11/2009 17:58:24
Apparently in this case I do, pal.

I tested it using this:
function room_AfterFadeIn() {
  StartCutscene(eSkipESCOnly);
  player.Walk(0, 180);
  Wait(20);
  mouse.Mode = eModePointer;
  gChoice.Visible = true;
  player.Walk(319, 180);
  EndCutscene();
}


The GUI stops Roger's walk dead in its tracks, as expected. As soon as I press the button, the GUI disappears and Roger resumes walking. (The new panel of the default game does exhibit the exact same behaviour, btw)
The thing is, even if it didn't, like I said, the GUI would be turned on at the end of the script anyway.

Please get your shit straight before lecturing people.
Title: Re: Question to the user while playing
Post by: NsMn on Mon 23/11/2009 18:23:59
Jesus, learn to read. What I was talking about was:

Quote from: NsMn on Mon 23/11/2009 16:31:11
It pauses the GAME, not the running SCRIPT. So it's better to use the module for this case.

You don't know everything better Khris.

Because, instead of writing a whole new script just for the GUI, you can just add one Line instead of the Gui.Visible command and you're done.
Title: Re: Question to the user while playing
Post by: Khris on Mon 23/11/2009 19:35:05
It does pause the running script.
So why go through all the trouble of downloading/adding the module and using it when all is needed are a simple GUI and a few lines of code?
Title: Re: Question to the user while playing
Post by: suicidal pencil on Mon 23/11/2009 20:51:43
Quote from: Khris on Mon 23/11/2009 19:35:05
...why go through all the trouble of downloading/adding the module and using it when all is needed are a simple GUI and a few lines of code?

Because it's apparently easier to take five minutes searching and downloading a module you'll only use once, so that you don't need to build a quick GUI, and write a few lines of code

NsMn, do you not like GUIs?Blasphemy!...and you shouldn't attempt to call out someone who probably has much more coding and programming experience, since they might actually know more than you.