Condições

Verificar se algo é verdadeiro ou falso

Sintaxe Básica

if CONDIÇÃO:
    # código se verdadeiro

if CONDIÇÃO:
    # código se verdadeiro
else:
    # código se falso

if CONDIÇÃO1:
    # primeiro
else if CONDIÇÃO2:
    # segundo
else:
    # fallback

Negação

Use doesn't, don't ou is not para negar:

if player has permission "admin":
    # tem permissão

if player doesn't have permission "admin":
    # não tem permissão

if player is not online:
    # offline

Comparações Numéricas

OperadorSignificado
>Maior que
>=Maior ou igual
<Menor que
<=Menor ou igual
=Igual
!=Diferente
if player's health > 10:
    send "Healthy!"

if player's balance >= 100:
    send "Rich!"

if {score} < 50:
    send "Low score"

if {count} = 0:
    send "Empty"

if {level} != 1:
    send "Not level 1"

Comparações de String

if message contains "hello":
    send "Hi back!"

if message starts with "/":
    cancel event

if message ends with "!":
    send "Excited!"

if player's name is "Steve":
    send "Hello Steve!"

Permissões

if player has permission "admin":
    send "You're admin!"

if player doesn't have permission "build":
    cancel event
    send "You can't build here!"

Estado do Player

Online/Offline

if {_target} is online:
    teleport player to {_target}
else:
    send "Player is offline!" to player

Gamemode

if player's gamemode is survival:
    send "Survival mode!"

if player is in creative:
    send "Creative mode!"

Movimento

if player is flying:
    send "You're flying!"

if player is sneaking:
    send "Sneaky!"

if player is sprinting:
    send "Running!"

Vida e Fome

if player's health < 5:
    send "&cLow health!"

if player's food < 10:
    send "&eLow hunger!"

Itens

# Tem item no inventário
if player has diamond:
    send "You have diamonds!"

if player has 64 diamond:
    send "Full stack!"

# Segurando item
if player is holding diamond_sword:
    send "Nice sword!"

# Vestindo armadura
if player is wearing diamond_helmet:
    send "Diamond head!"

Variáveis

# Está definida
if {home::%player%} is set:
    teleport player to {home::%player%}

if {_target} is not set:
    send "Missing target!"

# Está vazia
if {list::*} is empty:
    send "List is empty!"

# Contém
if {admins::*} contains player's name:
    send "You're an admin!"

Combinando Condições

Use and e or para combinar:

if player has permission "vip" and player's balance >= 1000:
    send "VIP with money!"

if player's health < 5 or player's food < 5:
    send "You need help!"

if player is sneaking and player is holding diamond:
    send "Secret action!"
    give 10 emerald to player

Dica

Condições são avaliadas da esquerda para direita. Use parênteses mentalmente para clareza, mas o Lazuli não suporta parênteses explícitos ainda.