☄️
SpaceTode
  • Introduction
  • Element
  • Properties
  • Data
  • Arguments
  • Rules
  • Diagrams
  • Inputs
  • Outputs
  • Transformations
  • Symmetries
  • Symbols
  • Event Arguments
  • Maybe
  • Point of View
  • Actions
  • Mimic
  • Sub-Elements
  • Blocks
  • Scoping
  • JavaScript
  • Behave
  • Tabs and Spaces
Powered by GitBook
On this page

Was this helpful?

Rules

PreviousArgumentsNextDiagrams

Last updated 4 years ago

Was this helpful?

You can give an element rules by drawing rule diagrams:

element Sand {
    @ => _
    _    @
}

An element's rules show how it acts in the world. It checks its surroundings to see if it matches the left-hand-side of the rule (the inputs). If it matches, it changes it to look like the right-hand-side of the rule (the outputs). Rules are checked in order. The first rule to match is the one that gets used.

Check out the page for more information on diagrams.

Rule Keyword

You can optionally use the rule keyword, which may improve readability in longer elements:

element Sand {
    rule {
        @ => _
        _    @
    }
}
diagrams