I'm having trouble trying to figure out some scripting using an 'if' function. My intention is that if one object's visibility is turned off by a mouse click that this will trigger another item's visibility to turn on. I've been scanning through the video tutorials for some guidance, as I recalled seeing if functions being used there, and I've had a look through the AGS wiki too. I'm probably missing something, but any help would be really appreciated.
My code looks like this:
Quote
function carkeys_AnyClick()
{
carkeys.Visible = false;
if (carkeys.Visible = false){
carkeyicon.visible = true;}
}
I tried to run this code but the error I get is
Quote
Error (line 33): Parse error in expr near 'carkeys'
The thing is, I'm not sure what that even means.
function carkeys_AnyClick(){
carkeys.Visible = false;
if (carkeys.Visible == false){
carkeyicon.visible = true;
}
}
When you put = to an if statement it should be ==
The code above should work fine.
I'd ditch the if statement though because you always set the visible to false therefore before the if statement is run carkeys will always be off. But well, anyway.
Also remember that == checks a statement, = sets a statement.
Also parse errors are mostly concerning syntax thingies.
Also just noticed shouldn't the carkeyicon. visible =true; , be carkeyicon.Visible=true;?
Thank you guys! It works like a charm and I'll certainly keep the tip about the = marks in mind.