Skip to content

Abstractions for creating and exporting .sb3 files.

License

Notifications You must be signed in to change notification settings

mybearworld/sb3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@mbw/sb3

Abstractions for creating and exporting Scratch project (.sb3) files.

Note

This package is not affiliated with Scratch or the Scratch foundation.

import { block, Script, Project, Target } from "@mbw/sb3";

using EMPTY_FILE = await Deno.open("./empty.svg");
const EMPTY_SVG = EMPTY_FILE.readable;

const project = new Project();

const sprite = new Target("sprite");
sprite.costumes.push({
  name: "Blank",
  file: EMPTY_SVG,
  type: "svg",
});
sprite.addScript(
  new Script({ topLevel: true }).push(block("event_whenflagclicked")).push(
    block("looks_sayforsecs", {
      inputs: {
        MESSAGE: { type: 10, value: "Hello, world!" },
        SECS: { type: 4, value: "2" },
      },
    })
  )
);
project.addTarget(sprite);

const stage = new Target();
stage.costumes.push({
  name: "Blank",
  file: EMPTY_SVG,
  type: "svg",
});
project.addTarget(stage);

const zip = await project.zip();
await Deno.writeFile("project.sb3", zip);

About

Abstractions for creating and exporting .sb3 files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published