Two GUI button problems (SOLVED)

Started by Akril15, Fri 25/04/2008 10:02:07

Previous topic - Next topic

Akril15

Hello,

I've been repeatedly trying to find a solution to this small but annoying problem, but after a couple of months, I've finally given up and decided to ask for help here:

My game (which I'm making in AGS 2.72) starts with a simple GUI that I made into a splash screen where the player has the option to start a new game, restore an old one, or quit. However, I'm using Joe Carl's combination Save/Load GUI (since I was unable to make a Save/Restore GUI by myself), so currently the GUI that pops up if the player clicks on Restore gives him the option of saving the game on the splash screen, which is not something I want.

I'm trying to make the "Save" button invisible when the player restores a game from the splash screen (using variables to determine whether the button is visible or not). Unfortunately, I've been unable to accomplish this, because I always get an “undefined token” error message.  I've repeatedly searched the forums and the manual, but haven't been able to find how to properly "define" the button.

Code: ags

////////////////////////////////////////////////
// SaveRestore-GUI                                   //
////////////////////////////////////////////////
if (interface == 6) { 
if (GetGraphicalVariable("menu") == 1) {

btnSaveGame.Enabled = false;
}



Also, I have an animated (unclickable) button on the same GUI, but it won't animate when I access the Save/Restore GUI from the game's splash screen. Here's its code (which I've inserted at the very beginning of the SaveRestore-GUI block):

btnimage.Animate(23, 5, 1, eRepeat);

Any help would be much appreciated.

Thank you.

Khris

Look up the scriptname of the button. Then use that in the code.
You've probably mistakenly put "btn" in front of the name, I bet it's called just "SaveGame", right?
Code: ags
SaveGame.Visible = false;

(Also, why don't people pay any attention to the auto-complete window...? I don't get it.)

About the second problem: there's no GUIButton.Animate command; you have to animate buttons manually.

Akril15

Ah, darn...I misunderstood the GUI Button Enabled section of the manual and was under the impression that all GUI buttons needed to have "btn" in front of them. Stupid, stupid, stupid.

I fixed the button's name, and I'm not getting the "undefined token" error anymore, but when I click on the restore button on the splash screen, the Save button is still visible on the Save/Restore GUI.

QuoteAbout the second problem: there's no GUIButton.Animate command; you have to animate buttons manually.
I'm afraid I don't quite understand -- the button does animate when I access the Save/Restore GUI from anywhere else in the game, but not when I access the GUI from the splash screen.

Pumaman

In the GUI editor, double-click the Restore button on the splash screen, and paste your "Enabled = false" code into its event handler.

QuoteAbout the second problem: there's no GUIButton.Animate command; you have to animate buttons manually.

Get with the times, man ;)

Quote
I'm afraid I don't quite understand -- the button does animate when I access the Save/Restore GUI from anywhere else in the game, but not when I access the GUI from the splash screen.

Is the splash screen set as a popup modal GUI? If so it is probably pausing the game and thus animations may not be running.

Alternatively, when you say that you've inserted the Animate code at "the very beginning of the SaveRestore-GUI block", where exactly do you mean by that?

Khris


Akril15


Quote from: Pumaman on Mon 28/04/2008 15:36:51
Is the splash screen set as a popup modal GUI? If so it is probably pausing the game and thus animations may not be running.

Alternatively, when you say that you've inserted the Animate code at "the very beginning of the SaveRestore-GUI block", where exactly do you mean by that?
[/quote]
The splash screen isn't a popup modal, and the Save/Restore "block" is the section of code in the global script used by the Save/Restore GUI (for lack of a better description).

However, inspired by your solution to my first problem, I tried moving the "animate button" line to the Restore button's event handler as well, and lo and behold, now the button animates. Thank you very much.

SMF spam blocked by CleanTalk