Gez
Why don't I have a custom title by now?!
Posts: 9139
Registered: 07-07 |
Khorus said:
Hello helpful programmer genius types,
I want a switch to lower a floor while requiring the Oracle Key to do so. The script compiler complains that the "else" line in the following code is an invalid statement. I'm completely hopeless when it comes to anything code related, so any help here would be wunderbar! :D
code:
script 5 (void)
{
ACS_LockedExecute(6,0,6,0,15);
}
script 6 (void)
{
if (CheckInventory("OracleKey"))
Print(s:"The way is open.");
{
Floor_LowerToLowest(15,14);
}
else
Print(s:"You require the Oracle Key.");
}
Your "Print(s:"The way is open.");" is not in the curly-brace block. Therefore, it is the only thing executed conditionally. The block that comes after (with Floor_LowerToLowest()) is executed inconditionally, so it would always happen. It's "detached" from the if.
When you arrive at the else, it is no longer connected to the if, so it invalid.
The fix is simply to move the Print line inside the block.
|