custom GUI scripting help. making a button visible only when condition is met.

Started by AstroTramp, Wed 09/10/2019 20:57:49

Previous topic - Next topic

AstroTramp

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?

Cassiebsg

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;
There are those who believe that life here began out there...

VampireWombat

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

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


edit: Or do what Cassie said.

AstroTramp

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!

Khris

Yes, for reference, you can turn buttons invisible by adding something like
Code: ags
  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

SMF spam blocked by CleanTalk