
02-01-2010, 11:46 AM
If else if statements are like a fork in the road when the Alice world is running. If the condition (the thing at the top that initially says true, but can be changed to any boolean value or expression) is true, the top event is done. If not, the bottom is done.
Try this: Create a grass world with a bunny. Now, open the scripting area (the big yellow area that you can drag tiles onto) and drag an if/else if statement onto it. Now, drag a bunny move method into the top (do nothing) area of the if/else if statement.
If you play your world, the bunny will move up because true is selected on the if/else if statement.
Now, go back and change the true value to false and replay your world. The bunny should not move at all, because the top event, the one that only happens if the condition is true, was skipped and the bottom one, the one that says to do nothing, was done instead.
Experiment with trying to drop different things onto the condition of the if/else if statement to see just what kinds of choices you can have the world make based on the conditions of the world. There are TONS of possibilities, so go nuts!
|