Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ostyster on Thu 04/08/2016 00:07:59

Title: GUI Visability Parse problem
Post by: Ostyster on Thu 04/08/2016 00:07:59
I want to make a GUI invinsible while other GUI's are shown and i tried

Code (ags) Select

if ((gInventory.Visible = true) ||
      (gPanel.Visible = true) ||
      (gSaveGame.Visible = true) ||
      (gRestoreGame.Visible = true) ||
      (gRestartYN.Visible = true) )
  {
    gTextbox.Visible = false;
  }
  else
  {
    gTextbox.Visible = true;
  }


But if i want to run the game an error shows up saying:
Parse error in expr near 'gInventory'

I don't know what the problem is.
Please help me with my code or give me an alternative.
Title: Re: GUI Visability Parse problem
Post by: Crimson Wizard on Thu 04/08/2016 00:26:41
This is simple, when you are writing conditions, equality check is done with "==", not "=".

"=" - is assignment, like "make X be 5".
"==" - is equality check operator "check that X equals to Y".
Title: Re: GUI Visability Parse problem
Post by: Ostyster on Thu 04/08/2016 00:33:44
Thanks there is no error anymore but sadly the box doesn't get invisible
Title: Re: GUI Visability Parse problem
Post by: Crimson Wizard on Thu 04/08/2016 00:48:15
Quote from: Ostyster on Thu 04/08/2016 00:33:44
Thanks there is no error anymore but sadly the box doesn't get invisible
That really depends on something else then. Like, where is this particular piece of code located in script, and does it gets called at all?
Title: Re: GUI Visability Parse problem
Post by: Ostyster on Thu 04/08/2016 10:55:47
Ok i got it to work.
you hve to put this under "function repeatedly_execute() {"

Code (ags) Select

if ((gInventory.Visible == true) ||
    (gPanel.Visible == true) ||
    (gSaveGame.Visible == true) ||
    (gRestoreGame.Visible == true) ||
(gRestartYN.Visible == true))
{
    gTextbox.Visible = false;
}
else
{
    gTextbox.Visible = true;


Then the GUI Textbox gets displayed while walking around but not when any other GUI (exept iconbar) is visible.
Title: Re: GUI Visability Parse problem
Post by: Matti on Thu 04/08/2016 15:49:45
Btw, you don't need that many brackets and the "== true" isn't necessary. So you could write it like this:

Code (ags) Select

if (gInventory.Visible ||
    gPanel.Visible ||
    gSaveGame.Visible ||
    gRestoreGame.Visible ||
    gRestartYN.Visible)

    gTextbox.Visible = false;

else gTextbox.Visible = true;
Title: Re: GUI Visability Parse problem
Post by: Crimson Wizard on Thu 04/08/2016 18:40:42
Quote from: Matti on Thu 04/08/2016 15:49:45
Btw, you don't need that many brackets and the "== true" isn't necessary. So you could write it like this:

Code (ags) Select

if (gInventory.Visible ||
    gPanel.Visible ||
    gSaveGame.Visible ||
    gRestoreGame.Visible ||
    gRestartYN.Visible)

    gTextbox.Visible = false;

else gTextbox.Visible = true;


While I agree on what you did to simplify condition, I cannot agree with curvy brackets removal and putting "gTextbox.Visible = true" on same line with "else". Firstly, such things are related to chosen coding style, on other hand with multiline condition like that I find Ostyster's original code much easier to read.
Title: Re: GUI Visability Parse problem
Post by: Khris on Sat 06/08/2016 12:36:29
Ok then :-D
gTextbox.Visible = !(gInventory.Visible || gPanel.Visible || gSaveGame.Visible || gRestoreGame.Visible || gRestartYN.Visible);