Yes, your code allows to run two ChangeRoom commands in a sequence.
First is run if PlugIn = true, and then the second runs if SinkFilled is either true or false.
To deal with situations like this you need to exit the function prematurely. This is what "return" command for ().
Code: ags
Another way is to use "else if" structure, in which case only one of the blocks can be processed at a time:
Code: ags
I actually think that the second solution is better in this particular case, because you do not have anything else in this function.
First is run if PlugIn = true, and then the second runs if SinkFilled is either true or false.
To deal with situations like this you need to exit the function prematurely. This is what "return" command for ().
{
if (PlugIn==true)
{
cEgo.Walk(575, 650, eBlock, eWalkableAreas);
cEgo.ChangeRoom(8, 0, 0);
return; // this terminates function and returns back to where it was called
}
<...>
}
Another way is to use "else if" structure, in which case only one of the blocks can be processed at a time:
{
if (PlugIn==true)
{
cEgo.Walk(575, 650, eBlock, eWalkableAreas);
cEgo.ChangeRoom(8, 0, 0);
}
else if (SinkFilled==true)
{
cEgo.Walk(575, 650, eBlock, eWalkableAreas);
cEgo.ChangeRoom(9, 0, 0);
}
else
{
cEgo.Walk(575, 650, eBlock, eWalkableAreas);
cEgo.ChangeRoom(2, 0, 0);
}
}
I actually think that the second solution is better in this particular case, because you do not have anything else in this function.