Selection - pantonshire/Vulcan GitHub Wiki

If statements

If statements allow you to only run a section of your code if a certain condition is met. This condition is a boolean, which means that it's either true or false. If it's true, then the code runs. If it's false then it isn't.
The basic syntax for an if statement in Vulcan is:

if CONDITION then
    ...
end if

The "..." is a placeholder for all of the code that you want inside the if statement. CONDITION is the boolean condition which must be true in order for the code to run. You must end your if statement with "end if" in order to show Vulcan where it ends.

Otherwise statements

Otherwise statements can be used after an if statement. They're called "else" statements in most other languages, but I thought that the word "otherwise" would be easier to understand. The code inside an otherwise statement will only be run if the if statement before it did not run.
For example:

if player's health is less than 5 then
   tell player to heal 1 health
otherwise
   tell player to take 1 damage
end if

will heal the player by 1 if their health is less than 5, but damage them if it isn't.
Otherwise statements can also have conditions, for example:

if player's health is less than 5 then
   tell player to heal 1 health
otherwise if player's health is less than 9 then
   tell player to take 1 damage
end if

If the player's health is less than 5, the code will heal them by 1. Otherwise, if it's less than 9, it will cause them to take 1 damage. If it's 9 or more, then nothing happens at all.