I start from a empty game and i create a new GUI to display some basic info from the game (time played, money, etc). The GUI is called inventario. It popup when you press enter:
In the global script =
#sectionstart on_key_press // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) {
// called when a key is pressed. keycode holds the key's ASCII code
if (IsGamePaused() == 1) keycode=0; // game paused, so don't react to keypresses
if (keycode==13) {
gInventario.Visible = true; // Enter muestra cosas
mouse.Mode = eModePointer;
}
}
#sectionend on_key_press // DO NOT EDIT OR REMOVE THIS LINE
Now, i created a button in the GUI, called Boton_Inventario_Ok, to switch off the gui when you press it; on left click = run script and in the click option i wrote Boton_Inventario_Ok_Click.
Then i added this function in the global script=
#sectionstart Boton_Inventario_Ok_Click // DO NOT EDIT OR REMOVE THIS LINE
function Boton_Inventario_Ok_Click(GUIControl *control,MouseButton button) {
// They pressed the OK button, close the GUI
gInventario.Visible = false;
mouse.UseDefaultGraphic();
}
#sectionend Boton_Inventario_Ok_Click // DO NOT EDIT OR REMOVE THIS LINE
But the GUI do not close, and of course, i cant continue playing. Any idea where is the mistake? I forgot something? I where looking for some info but i do not found nothing i were able to understand as helpfull.
JpGames
Quote from: JpGames on Wed 11/04/2007 05:54:38and in the click option i wrote Boton_Inventario_Ok_Click
[...]
Then i added this function in the global script
If the button has a Script name and Left click is set to Run script, double-clickling Click will show the window where you can enter the function's name, but [Script name]_Click will already be the contents of the text field, so you shouldn't have had to write it in there.
After confirming the function name, double-clicking the GUI button itself will get AGS to add the function; again you don't have to write it yourself. (Which I guess was what you did, going by what I quoted from your post and the missing space infront of "MouseButton".)
Since the code inside looks fine, I'm pretty sure the function doesn't get called, even if it looks as if it should.
You can always debug something like that easily by adding a Display("test"); line to the piece of code in question, in this case the function.
Solved. Mi fault were that i included the function inside the repeteadly execute :-[
Thanks
JpGames