Adventure Game Studio | Forums

AGS Support => Beginners' Technical Questions => Topic started by: AstroTramp on 09 Oct 2019, 20:57

Title: custom GUI scripting help. making a button visible only when condition is met.
Post by: AstroTramp on 09 Oct 2019, 20:57
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?
Title: Re: custom GUI scripting help. making a button visible only when condition is met.
Post by: Cassiebsg on 09 Oct 2019, 21:42
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

buttonName.Visible=true;
Title: Re: custom GUI scripting help. making a button visible only when condition is met.
Post by: VampireWombat on 09 Oct 2019, 21:45
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;
  4.  

edit: Or do what Cassie said.
Title: Re: custom GUI scripting help. making a button visible only when condition is met.
Post by: AstroTramp on 10 Oct 2019, 00:03
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!
Title: Re: custom GUI scripting help. making a button visible only when condition is met.
Post by: Khris on 10 Oct 2019, 16:04
Yes, for reference, you can turn buttons invisible by adding something like
Code: Adventure Game Studio
  1.   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 (https://www.adventuregamestudio.co.uk/manual/ags56.htm#topic53)