pod.js Documentation

Overview

pod.js is inspired by Scratch and is intended to make it easy for Scratch users to learn JavaScript by bringing over familiar concepts:

JavaScript Library Documentation

To initialize the environment and create and register scripts with Sprites and Stages, you use the JavaScript classes directly. In most cases, you only need to write code like:

var env = new PodJS();
var scratch = env.pod("scratch");
var robot = scratch.newSprite("robot");
robot.loadCostume("costume1", "img/Cartoon_Robot_a.png");
robot.loadCostume("costume2", "img/Cartoon_Robot_b.png");
In more advanced cases, you should consult the pod.js JsDocs (try looking at Sprite, for example):

Open pod.js JsDoc

Scratch Blocks

Blocks are intended to behave identically to blocks in Scratch, and take the same number of parameters. See the Scratch Wiki for details. To pass parameters to blocks, just add more blocks, separating each one with dots, like so:

robot.newScript().
    when_green_flag_clicked.
    forever.begin.
        costume.c("costume2").
        move.c(10).
        wait.c(1).
        costume.c("costume1").
        move.c(-10).
        wait.c(1).
    end;

To pass in a constant value, use the 'c' block, and provide the value in parenthesis, like c(10).

For advanced users, if you'd like to use pure JavaScript code in your Scratch Blocks, you can use the 'f' block, like so:

        move.f(function() { return 5 + 5; }).

The following Scratch blocks are provided by pod.js. Blocks that are implemented have a checkmark next to them. Others are not yet implemented but coming soon!

Motion Blocks
  • move steps
  • turn
  • turn_cc
  • point_dir degrees
  • point_at
  • go_xy x y
  • go_to
  • glide
  • change_x x
  • set_x
  • change_y y
  • set_y
  • if_on_edge_bounce
  • set_rotation_style
  • x
  • y
  • direction
Looks Blocks
  • costume name
  • backdrop
  • next_costume
  • next_backdrop
  • say_for
  • think_for
  • think
  • change_effect
  • set_effect
  • clear_effects
  • change_size
  • size
  • show
  • hide
  • to_front
  • back
  • costume_number
  • backdrop_number
  • backdrop
  • size
Sound Blocks
  • play_sound name
  • play_sound_until_done
  • stop_all_sounds
  • play_drum_for_beats
  • rest_for_beats
  • play_note_for_beats
  • set_instrument_to
  • change_volume_by
  • set_volume_to_percent
  • change_tempo_by
  • set_tempo_to_bpm
  • volume
  • tempo
Pen Blocks
  • clear
  • stamp
  • pen_down
  • pen_up
  • set_pen_color_to_color
  • change_pen_color_by
  • set_pen_color_to_number
  • change_pen_shade_by
  • set_pen_shade_to
  • change_pen_size_by
  • set_pen_size_to
  • stamp_transparent
Event Blocks
  • when_green_flag_clicked
  • when_key_pressed
  • when_sprite_clicked
  • when_backdrop_switches_to
  • when_greater
  • when_receive message
  • broadcast message
  • broadcast_and_wait
Control Blocks
  • when_start_as_clone
  • wait seconds
  • wait_until condition
  • create_clone_of
  • repeat times begin body end
  • forever
  • if_then condition begin body end
  • otherwise begin body end
  • repeat_until condition begin body end
  • stop
  • delete_this_clone
Sensing Blocks
  • ask_and_wait
  • reset_timer
  • set_video_transparency_to_percent
  • touching name
  • touching_color
  • color_is_touching
  • key_pressed
  • mouse_down
  • distance_to
  • answer
  • mouse_x
  • mouse_y
  • loudness
  • timer
  • video_on
  • of
  • current
  • days_since_2000
  • username
Operators Blocks
  • less a b
  • equals a b
  • greater a b
  • and
  • or
  • not a
  • plus
  • minus
  • times
  • divided_by
  • random_from_to from to
  • join a b
  • letter_of
  • length_of
  • mod
  • round
  • of
Data Blocks
  • set_to variable value
  • change_by variable amount
  • show_variable name
  • hide_variable name
  • variable name
  • add_to value name
  • delete_of index name
  • insert_at_of
  • replace_item_of_with
  • show_list name
  • hide_list name
  • item_of index name
  • length_of name
  • contains