Skip to content

Templates

Shaye Garg edited this page Sep 29, 2021 · 8 revisions

Templates and behavior expressions are what lets you actually do stuff with behave.

What is a template?

A template is essentially a function that can be used inside the behavior element (or inside other templates).

The template can then generate behavior expressions according to the arguments it receives.

Behavior expressions

behave has many behavior expressions:

  1. use
  2. component
  3. animation
  4. visible
  5. emissive
  6. interaction
  7. events
  8. update
  9. inputevent

Writing a template

A template definition has the form:

template <ident>(<args>) {
    <anything_that_can_go_in_behavior>
}

anything_that_can_go_in_behavior:

  1. Any behavior expression
  2. An expression that either evaluates into a behavior expressions or none (like ifs and switches.
  3. Variable declarations.
Clone this wiki locally