Syntax: if(condition) { }


Using the if language construct, you can perform conditional checks before executing code. The if construct can be paired with conditional statements, or can be left alone for a true/false check. If the condition is true, then the code is executed.

Conditional Statements

x == yx is equal to y
x != yx is not equal to y
x > yx is greater than y
x >= yx is greater than or equal to y
x < yx is less than y
x <= yx is less than or equal to y
x in y[]x is in array y
!(statement)Using ! means that the opposite of a statement is true
x && yx and y are true
x || yx or y is true


Using normal conditional statments:

if (player.account == "LoneAngelIbesu")
  echo("Welcome, LoneAngelIbesu.");

if (player.account in {"Skyld", "LoneAngelIbesu", "Inverness"})
  echo("You are either Skyld, LoneAngelIbesu, or Inverness.");

Using the exclamation point, you can check if a statement is the opposite:

if (!(player.account in {"Skyld", "LoneAngelIbesu", "Inverness"})) {
  echo("You are not Skyld, LoneAngelIbesu, or Inverness.");

You can check if the result of a function is true or false like so:

if (functionName())
  echo("The function returned true.");

if (!functionName())
  echo("The function returned false.");

You can check if a variable is true or false:

if (this.variable)
  echo("The variable is true.");

if (!this.variable)
  echo("The variable is false.");



There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki