Importing Scratch projects (SB3)#
blockst can read real Scratch 3 project files (.sb3) and extract scripts, variables, lists, images, and screen previews.
Basic Workflow#
#let project = read("my-project.sb3", encoding: none)
#sb3.render-sb3-scripts(project, language: "en", target: "Sprite1")The .sb3 file must be read as raw bytes (encoding: none).
render-sb3-scripts()#
#sb3.render-sb3-scripts(
sb3-bytes, // raw .sb3 file bytes (read with encoding: none)
script-number: auto, // global script index (1-based)
target-script-number: auto, // script index within selected target
target: auto, // filter by target name ("Stage", sprite name, or auto for all)
sb3-plugin: auto, // WASM plugin path (auto = bundled plugin)
language: "en", // locale for block text
show-headers: auto, // show target name header
header-gap: 1.5mm, // spacing between target name and scripts
script-gap: 3mm, // spacing between individual scripts
)render-sb3-variables()#
#sb3.render-sb3-variables(
sb3-bytes, // raw .sb3 file bytes
target: auto, // filter by target name
target-variable-name: auto, // filter by variable name
target-variable-number: auto,// variable index within target (1-based)
sb3-plugin: auto, // WASM plugin path
language: "en", // locale for display text
show-target-headers: auto, // show target name header
target-gap: 2mm, // spacing between targets
item-gap: 0.8mm, // spacing between variable items
)render-sb3-lists()#
#sb3.render-sb3-lists(
sb3-bytes, // raw .sb3 file bytes
target: auto, // filter by target name
target-list-name: auto, // filter by list name
target-list-number: auto, // list index within target (1-based)
sb3-plugin: auto, // WASM plugin path
language: "en", // locale for display text
show-target-headers: auto, // show target name header
target-gap: 2mm, // spacing between targets
item-gap: 0.8mm, // spacing between list items
)Standalone Monitors#
list-monitor()#
#list-monitor(
name: "List", // display name shown in header
items: (), // array of values to display
width: 5.2cm, // monitor width
height: auto, // auto-grows to fit content
length-label: auto,// show length indicator (e.g. "length: 3")
)variable-monitor()#
#variable-monitor(
name: "Variable", // display name shown in header
value: 0, // current value to display
)screen-preview()#
#sb3.sb3-screen-preview(
sb3-bytes, // raw .sb3 file bytes
width: 480, // stage rendering width in pixels
height: 360, // stage rendering height in pixels
unit: 1, // size multiplier (2 = double size)
background: none, // override background color
show-border: true, // show stage border
show-backdrop: true, // show costume/backdrop image
monitor-scale: 1.5, // scale factor for variable/list overlays
language: auto, // locale for monitor text
)Renders a static Scratch stage preview with sprites, backdrop, and monitors.
Image Helpers#
// List all image assets in the project
#sb3.sb3-image-assets-catalog(sb3-bytes, target: auto)
// Render a single image asset
#sb3.sb3-image(
sb3-bytes, // raw .sb3 file bytes
target: auto, // filter by sprite/stage name
image-number: auto, // global image index (1-based)
target-image-number: auto, // image index within target (1-based)
image-name: auto, // filter by image name (e.g. "costume1")
width: auto, // output width (auto = original size)
height: auto, // output height
)Catalog Helpers#
// Grouped script metadata (targets, scripts, blocks count)
#sb3.sb3-scripts-catalog(sb3-bytes)
// Target states (variables, lists, and sprite properties)
#sb3.sb3-state-catalog(sb3-bytes)
// Convert a specific SB3 script to Scratch text
#sb3.sb3-bytes-to-scratch-text(
sb3-bytes, // raw .sb3 file bytes
script-number: auto,// global script index (1-based)
language: "en", // locale for output text
)