function hHotspot1_AnyClick()
{
if (Lamp == true)
player.Walk(63, 38, eBlock);
player.ChangeRoom(27, 140, 55); {
{
if (Lamp == false)
player.Walk(63, 38, eBlock);
player.ChangeRoom(21, 140, 55); {
}
}
}
}
but its saying I can't do the second location cause I already have the first location. any way around this?
Your IF statement / brackets aren't quite right
function hHotspot1_AnyClick() {
if (Lamp == true) {
player.Walk(63, 38, eBlock);
player.ChangeRoom(27, 140, 55);
} else {
player.Walk(63, 38, eBlock);
player.ChangeRoom(21, 140, 55);
}
}
We check if the lamp is true, otherwise we do something else
thanks! everytime I try to put else statements I always get parser error's so I have been trying to avoid them.
That's because you've placed the brackets arbitrarily; with the exception of the function block ones, none of them has any effect.
if (...) // no brackets, so will only affect a single statement
statement1; // affected by if
statement2; // not affected by if, just regular statement
else // thus: parse error: else without if
statement3;
Just follow this basic syntax:
if (...) { // open if-block
statement1;
statement2;
statement3;
} // end of if-block
else { // works fine, since else is right after if-block
..
} // end of else-block
(also: the player.Walk command is executed regardless of the variable's value so should be outside the if/else code.)