feature.traps
The feature.traps
API allows features to access important Scratch API's in the editor.
When dealing with new traps API's, we highly recommend exposing the feature variable. You can do so by finding an editor feature that uses modules and adding window.feature = feature
to it.
feature.traps.vm
This API allows features to access the virtual machine in the editor. Scratch's virtual machine manages running projects, and the API is also accessible from the GUI API.
Features using the API
Many or all of the features listed use the deprecated API for reaching the virtual machine. Do not reference their code when using the API for reasons other than compatability.
Feature ID | Use case |
start-stop-hotkeys | Start and stop projects. |
sprite-clones | Get the current sprite and its clones. |
project-timer | Detect a project starting/stopping and get the runtime. |
list-sprites | Get the current sprite's block count and coordinates. |
last-key-pressed | See when the project detects keys pressed. |
delete-sprites | Get all sprites and delete them. |
clone-counter | Get the total number of clones. |
Last updated: ScratchTools v3.1.1
feature.traps.blockly
The Blockly API controls the blocks workspace in the editor, and the blocks within the workspace itself.
Features using the API
Many or all of the features listed use the deprecated API for reaching Blockly. Do not reference their code when using the API for reasons other than compatability.
Feature ID | Use case |
add-last-option | Get blocks to add context menu option. |
block-log | Get recent Blockly events. |
collapse-blocks | Get blocks to add context menu option. |
colored-comments | Get editor comments and their parent blocks to set comment color. |
Last updated: ScratchTools v3.1.1
feature.traps.gui
This is a function that returns the Scratch editor GUI, which hosts the virtual machine, important project data, and more.
Features using the API
Many or all of the features listed use the deprecated API for reaching the GUI. Do not reference their code when using the API for reasons other than compatability.
Feature ID | Use case |
move-project-title-input | Set the title input to the project's title. |
start-stop-hotkeys | Check whether or not the project is running. |
slash-to-search | Check whether or not the project is running. |
unlisted-projects | Get the project ID. |
Last updated: ScratchTools v3.1.1
feature.traps.paint
This is a function that returns the Scratch paint editor's API. It contains important information such as the selected shapes, opened modals, and more.
Features using the API
Many or all of the features listed use the deprecated API for reaching the paint editor API. Do not reference their code when using the API for reasons other than compatability.
Feature ID | Use case |
special-editor-fonts | Set the font of the selected item. |
shared-clipboard | Set and get the current clipboard data. |
Last updated: ScratchTools v3.1.1
feature.traps.sound
This is a function that returns the Scratch sound editor's API. It contains important information and the ability to edit sounds.
Features using the API
Many or all of the features listed use the deprecated API for reaching the sound editor API. Do not reference their code when using the API for reasons other than compatability.
Feature ID | Use case |
pause-audio | Set the audio trimming and get the current time. |
echo-effect | Add the echo effect to the current sound. |
Last updated: ScratchTools v3.1.1