Metaprogramming
The Metaprogramming toolbox lets a graph work with the document it is in. Its largest part reads the document's asset library: images, sounds and tables stored inside the document file, so the document carries them wherever it goes. It also has Run Graph, which runs the current graph, nodes that count and inspect graphs, and Expose Object Properties, which shows the properties of any value as outputs.
Use it when a document should be self-contained: a game that carries its sprites, or a report that carries its data.
- Included in: Divooka Explore and Divooka Compute, every tier. In Compute, start a document from the General Purpose workload, or add the Platform reference with Add reference (
Ctrl+Shift+L). The Platform reference holds Operating System and Metaprogramming. - Maturity: Usable · Support: Tier 1 (proposed) · what these mean
- Open it: node library (
Ctrl+Shift+Space) → Metaprogramming, or search for a node withCtrl+Space. - Reference: Metaprogramming node reference
New to graphs? Start with Your first program.
Main ideas
The asset library lives in the document. Open it with the Asset library button on the toolbar and add files. A graph then reads them by path, such as /sprites/bird.png, with Get Library Image, Get Library Audio or Get Library Table.
Find assets by pattern. Get Assets takes a pattern: * matches any characters except /, ? one character, and ** any characters including /.
Example: a game that carries its own sprite
Open Glaze > Sky Hopper (Ctrl+Shift+E). The bird is an image in the document's asset library at /sprites/bird.png. Every frame, in the drawing steps, Get Library Image reads it by that path, Make Sprite (Scale 2, Centered on) turns it into a sprite, and Draw Sprite draws it at the bird's position. Make Sprite keeps what it made, so doing this every frame costs nothing. Because the image is inside the document, you can copy the single .dvk file to another computer and the game still has its bird.
To use your own file: add it to the asset library, then read it by the same path with the Get Library node for its type.
Tips and limits
- Get Library 16-bit Grayscale Image reads every level a 16-bit file holds, which matters for heightmaps and masks; Get Library Image reads 8 bits per channel.
- Assets make the document larger. Large videos or datasets are better kept as files beside the document and read with Operating System nodes.
What is in the toolbox
| Category | Some of its nodes |
|---|---|
| Media Assets Extensions | Get Assets, Get Assets In Directory, Get Assets With Extension, Get Assets With Extensions and 5 more |
| Basic Graph Queries | Connector Names, Get Graphs Count, Graphs Count |
| Host | Display, Get Features, Get Feature Set |
| Metaprogramming | Run Graph, Expose Object Properties |
See also
- Metaprogramming node reference
- The window - the toolbar's Asset library button.
- Toolboxes - every other toolbox.