Problem with 'if' function

Started by Marr, Sun 06/06/2010 13:59:03

Previous topic - Next topic

Marr

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.

Dualnames

Code: ags

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Atelier

Also remember that == checks a statement, = sets a statement.

Dualnames

Also parse errors are mostly concerning syntax thingies.
Also just noticed shouldn't the carkeyicon. visible =true; , be carkeyicon.Visible=true;?
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Marr

Thank you guys! It works like a charm and I'll certainly keep the tip about the = marks in mind.

SMF spam blocked by CleanTalk