Skip to content

Dottie 0.11.0

Choose a tag to compare

@sam-phinizy sam-phinizy released this 09 Nov 16:32

Counters, expressions and logic for interactive pages

  • Variables can be numbers. A page can keep a count, a step or a score as well as true-or-false switches.
  • Conditions are expressions. Show an element when count >= 3, stage % 2 == 0 or
    min(count * 2, 5) == 5: numbers, arithmetic, comparisons, && and ||, parentheses, and min, max, abs,
    floor, ceil, round and clamp. Existing conditions work as they did.
  • Clicks can compute. A click can set count to count + 1 or cycle a stage with (stage + 1) % 3, worked out
    from the state before the click.
  • Labels show values. Text like Clicked {count} times fills in as the page plays.
  • Click logic. For what expressions can't say, a page can carry JavaScript handlers that its clicks run. Each
    handler gets the variables and the click, and returns new values. It runs only on a click, in a sealed sandbox:
    no access to the page, the network, timers, the clock or randomness, and limits on time and memory, so the same
    click always gives the same result. A web page runs logic only when allowed (<dottie-player allow-logic>, or
    Allow when exporting HTML). Elsewhere, a click does its own Set and Toggle instead.
  • For agents: set_variable takes numbers, click_set takes numbers and expressions, set_logic and
    update_element click_run add logic, and simulate runs it. export_animation takes allow_logic. Scripts
    have dottie.logic() and click: {run}.

Compatibility

  • A drawing that uses number variables or computed clicks can't be opened by Dottie 0.10.0 or earlier.
  • dottie.js: <dottie-player> takes allow-logic and fires logicerror. The engine, dottie-logic.min.js (about
    850 KB), loads from beside the player only when a page with logic is clicked. dottie-compile --allow-logic
    puts it in the compiled script instead.