Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Candle on Wed 21/12/2005 02:02:48

Title: Message box yes or no
Post by: Candle on Wed 21/12/2005 02:02:48
Is there a command for a message box or do you need to make a gui with the yes or no buttons on it and what you want the yes or no to do?
Call the gui yes or no from a hotspot.
Title: Re: Message box yes or no
Post by: Candle on Wed 21/12/2005 03:52:50
I have the img to show what I want:
I'm going to need some help this if anyone has a little time to help me with this.
What I want the message box to control is if you get an eyeball from the dead guy you see sitting there.
Si when you click on him you get the message box ( i will add the text to message box) It wil would be "DO you want to take the Eyeball?"so if they say yes I will add the eyeball and no they don't take it.
(http://img470.imageshack.us/img470/554/yesyno8lw.th.png) (http://img470.imageshack.us/my.php?image=yesyno8lw.png)
Title: Re: Message box yes or no
Post by: Akumayo on Wed 21/12/2005 04:14:22
Isn't this what your looking for (probably not, considering you posted on it, but whatever, my ten cents):
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23869.0
Title: Re: Message box yes or no
Post by: Candle on Wed 21/12/2005 04:21:47
Thanks Akumayo, that would work just as well I think.
I'm going to read that post now and see how to use it.
Thank you for the help.
Title: Re: Message box yes or no
Post by: Akumayo on Wed 21/12/2005 04:34:11
Actually, if you're okay with not using a GUI, I've thought up a rather nice code with keypresses:

In global script top:

function YesOrNo() {
Ã,  Display("Yes (y) or No (n)");
Ã,  if (IsKeyPressed(89) == 1 || IsKeyPressed(78) == 1) {
Ã,  Ã,  if (IsKeyPressed(89) == 1) {
Ã,  Ã,  Ã,  return 1;
Ã,  Ã,  }
Ã,  Ã,  if (IsKeyPressed(78) == 1) {
Ã,  Ã,  Ã,  return 0;
Ã,  Ã,  }
Ã,  }
Ã,  else {
Ã,  Ã,  Display("You have to pick one!");
Ã,  Ã,  YesOrNo();
Ã,  }
}


In global script header:

import function YesOrNo();


Example of use:

Display("Do you really want to pick up the eyeball?!");
int pickitup = YesOrNo();
if (pickitup == 1) {
Ã,  Display("You take the eyeball.");
Ã,  player.AddInventory(ieyeball);
}
else {
Ã,  Display("You leave the eyeball alone.");
}

Will display the question, and then ask the player yes or no until they press and hold 'y' or 'n', and take action based on their answer.
Title: Re: Message box yes or no
Post by: Candle on Wed 21/12/2005 04:40:31
Man that works perfect .. Thanks so much for the help.
Title: Re: Message box yes or no
Post by: Akumayo on Wed 21/12/2005 04:41:51
No problem, I'm using it in a few of my 'games' because of its simplicity.  ;D