Syntax
if(condition, if_true)
if(condition, if_true, if_false)
if(condition, if_true, ...)
Evaluate an expression if a condition holds.
if(1 == 2, print('oops, maths broke'));
if()
can also be used as an expression. An extra argument can be specified to
act as an else
block.
message = if(player()~'gamemode' == 'creative',
'Hi cheater',
'Hello friend',
);
Unlike most programming languages there is no else if
. More conditions and
expression can be added as arguments to the if()
call.
if(gamemode == 'creative',
'player is in creative',
gamemode == 'survival',
'player is in survival',
'player is not in creative or survival',
);