I want to make a GUI invinsible while other GUI's are shown and i tried
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.
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".
Thanks there is no error anymore but sadly the box doesn't get invisible
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?
Ok i got it to work.
you hve to put this under "function repeatedly_execute() {"
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.
Btw, you don't need that many brackets and the "== true" isn't necessary. So you could write it like this:
if (gInventory.Visible ||
gPanel.Visible ||
gSaveGame.Visible ||
gRestoreGame.Visible ||
gRestartYN.Visible)
gTextbox.Visible = false;
else gTextbox.Visible = true;
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:
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.
Ok then :-D
gTextbox.Visible = !(gInventory.Visible || gPanel.Visible || gSaveGame.Visible || gRestoreGame.Visible || gRestartYN.Visible);