Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: AstroTramp on Wed 09/10/2019 20:57:49

Title: custom GUI scripting help. making a button visible only when condition is met.
Post by: AstroTramp on Wed 09/10/2019 20:57:49
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 Wed 09/10/2019 21:42:44
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 Wed 09/10/2019 21:45:19
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 (ags) Select

   btn1.NormalGraphic=20;
   btn1.MouseOverGraphic=21;
   btn1.PushedGraphic=22;


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 Thu 10/10/2019 00:03:50
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 Thu 10/10/2019 16:04:32
Yes, for reference, you can turn buttons invisible by adding something like
  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)