malformed if statement

F

filipe

Guest
i wrote some code that checks to see which room is it
if it is room1 it plays sound_wind
and if its room2 plays sound_cave
here is my code
Code:
if (room == room1);
{
sound_play(sound_wind)
}
if (room == room2);
{
sound_stop(sound_wind)
sound_play(sound_cave)
}
 

Tornado

Member
Do not put ; in the lines where you have "if" or "else".
Put ; in the lines where you have "normal" statements (assignments, function calls, script calls, ...):
Code:
if (room == room1)
{
    sound_play(sound_wind);
}
if (room == room2)
{
    sound_stop(sound_wind);
    sound_play(sound_cave);
}
What you did was exactly opposite of that. ;-)

There are also other "controlling statements" which also do not allow ; like
loops ("for", "while")
"with"
"switch", "case"
etc...
Whenever you are starting to "control" something you don't need ; because it is start of some logic/controlling flow.
 
Last edited:
Top