Author Topic: custom GUI scripting help. making a button visible only when condition is met.  (Read 210 times)

Hi, im new to AGS and have read through the manual looking for an answer to no avail. I am making a custom GUI where I want certain buttons to become available only after certain conditions are met.  Basically I am making an interface like a utility belt where the player adds functions such as grappling hook, flamethrower etc.. to use as they add these items to their utility.  So the buttons wont be available to use until the player learns or buys it or whatever. is there a way to only have a button appear after a certain condition is met, like with a variable or something?


  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Yes, of course. :)

Basically, change the visible setting from true to false.
Then once the player has gotten the item or the condition is meet, you just use the script command to make it visible

There are those who believe that life here began out there...


  • Not a chupacabra
    • I can help with animation
    • I can help with backgrounds
    • I can help with characters
    • I can help with play testing
There's more than one way it could be done. The complete newbie way would be to just have a new GUI each time a new button is added. Another is to add graphics for the buttons when time comes. If the buttons have no graphics associated with them and no text, they will be invisible.

So, something like

Code: Adventure Game Studio
  1.    btn1.NormalGraphic=20;
  2.    btn1.MouseOverGraphic=21;
  3.    btn1.PushedGraphic=22;

edit: Or do what Cassie said.

thanks! I have it pretty much figured out now. i was just confused about where to put the script and found that it works just the same as any other game startup scripts. i thought it might have had to go somewhere in the actual GUI script and i didnt see any place for it to go.. but i got it working now. thanks!

Yes, for reference, you can turn buttons invisible by adding something like
Code: [Select]
  btnGrapplingHook.Visible = false;in the  game_start  function of the global script.

Available methods and properties can be found in the manual under Scripting -> GUI Button functions and properties
Fail at Floaty Rog' now!  still having to deal with what games are going through