Fuze Arena Logo
  • Forum
  • Creations
    Catalogue Showcase
  • Help

if

Purpose

Conditionally execute a block of code when condition is true

Description

Execute a block of code only if the specified condition is true (1)

Syntax

if condition then ... endIf // ... is executed ONLY if condition is met

if condition then ... else ... endIf // if condition is met execute first ... otherwise execute second ...

Arguments

condition condition to be tested. This can be a compound condition using AND and OR

Example

setCamera( {0, 10, 10 }, { 0, 0, 0 } )
bright = 50
light = worldLight( { -5, -5, -5 }, white, bright )
lighton = true
ballmodel = loadModel( "Kat Deak/Discoball" )
ball = placeObject( ballmodel, { 0, 0, 0 }, { 10, 10, 10 } )

loop
    c = controls( 0 )
    if c.x and not lighton then
        light = worldLight( { -5, -5, -5 }, white, bright )
        lighton = true
    endIf
    if c.a and lighton then 
        removeLight( light )
        lighton = false
    endIf
    rotateObject( ball, { 0, 1, 0 }, 1.0 )
    drawObjects()
    printAt( 0, 0, "Press X to switch on the light" )
    printAt( 0, 1, "Press A to switch off the light" )
    update()
repeat

Associated Commands

and, else, endIf, if, or, then

logo

©2019 FUZE Technologies Ltd. FUZE is a registered trademark of FUZE Technologies Ltd. All rights reserved.

Useful links

  • Fuze Main Site
  • Fuze Arena on Twitter
  • Fuze Arena on Youtube
  • Download Buyer

Contact Information

  • FUZE Technologies Ltd
    15 Clearfields Farm
    Wotton Underwood
    Aylesbury, Buckinghamshire
    ​England, HP18 0RS

  • +44 (0) 1844 239 432

  • contact@fuze.co.uk

© Copyright FUZE Technologies Ltd. All rights reserved.