1. Home
  2. Docs
  3. General Programming
  4. Using Functions

Using Functions

Functions are great way for organizing and re-using your code.
In SceneMax we declare functions by name and do-end do code block for example:


function rotateRight = do
end do

We declared a function named rotateRight and attached to it a do-end do block.
Now let’s see a fully working program using function:


Sinbad is a model
David is a Sinbad

function rotateRight = do
  David.rotate(y+45) in 5 seconds
end do

function rotateLeft = do
  David.rotate(y-45) in 3 seconds
end do

do 10 times
  run rotateRight
  run rotateLeft
end do

Running this program will rotate Sinbad model left and right 10 times in a loop

Was this article helpful to you? Yes No

How can we help?