Script API
Every module, function and constant a script can reach. Read from a booted engine rather than the source, so derived constants are included and this cannot drift from what scripts actually see.
| Module | Functions | Constants | Available in |
|---|---|---|---|
audio | 2 | 0 | every language |
engine | 5 | 0 | every language |
fs | 4 | 0 | every language |
input | 9 | 165 | every language |
log | 5 | 0 | every language |
node | 28 | 0 | every language |
physics | 12 | 5 | every language |
physics2d | 9 | 5 | every language |
render | 22 | 0 | every language |
rng | 4 | 0 | every language |
scene | 7 | 0 | every language |
toml | 2 | 0 | every language |
ui | 38 | 14 | every language |
audio
Functions: play, stop_all
engine
Functions: args, delta, quit, reload_script, time
fs
Functions: exists, list, read, write
input
Functions: is_down, is_mouse_down, just_pressed, just_released, mouse_delta, mouse_just_pressed, mouse_just_released, mouse_position, scroll_delta
Constants (165):
| Name | Value |
|---|---|
KEY_0 | Key0 |
KEY_1 | Key1 |
KEY_2 | Key2 |
KEY_3 | Key3 |
KEY_4 | Key4 |
KEY_5 | Key5 |
KEY_6 | Key6 |
KEY_7 | Key7 |
KEY_8 | Key8 |
KEY_9 | Key9 |
KEY_A | A |
KEY_ABNT_C1 | AbntC1 |
KEY_ABNT_C2 | AbntC2 |
KEY_ADD | Add |
KEY_APOSTROPHE | Apostrophe |
KEY_APPS | Apps |
KEY_AT | At |
KEY_AX | Ax |
KEY_B | B |
KEY_BACK | Back |
KEY_BACKSLASH | Backslash |
KEY_C | C |
KEY_CALCULATOR | Calculator |
KEY_CAPITAL | Capital |
…and 141 more.
log
Functions: clear, error, info, recent, warn
node
Functions: add_child, attach_script, children, component_names, get_component, get_node, global_position, global_rotation_euler, global_scale, has_component, is_valid, name, parent, path, position, queue_free, remove_component, rotation_degrees, rotation_euler, scale, script_path, set_component, set_name, set_position, set_rotation_degrees, set_rotation_euler, set_scale, translate
physics
Functions: add_ball_collider, add_body, add_cuboid_collider, apply_impulse, clear, is_paused, linear_velocity, set_gravity, set_linear_velocity, set_paused, set_sleeping_allowed, sleeping_allowed
Constants (5):
| Name | Value |
|---|---|
BODY_DYNAMIC | dynamic |
BODY_KINEMATIC | kinematic |
BODY_STATIC | static |
SHAPE_BALL | ball |
SHAPE_CUBOID | cuboid |
physics2d
Functions: add_body, add_collider, angular_velocity, apply_impulse, linear_velocity, max_contact_impulse, set_angular_velocity, set_gravity, set_linear_velocity
Constants (5):
| Name | Value |
|---|---|
BODY_DYNAMIC | dynamic |
BODY_KINEMATIC | kinematic |
BODY_STATIC | static |
SHAPE_CIRCLE | circle |
SHAPE_RECT | rect |
render
Functions: camera_2d, camera_matrix, camera_pose, color, draw_line, draw_line_2d, mouse_ray, mouse_world_2d, set_app_icon, set_background, set_ball, set_camera, set_camera_2d, set_camera_input, set_circle, set_color, set_cuboid, set_grid, set_grid_colors, set_rect, shape, shape2d
rng
Functions: int, random, range, seed
scene
Functions: component_schema, component_types, get_node, instantiate, root, source, spawn
toml
Functions: encode, parse
ui
Functions: add_space, available_height, available_width, bottom_panel, central_panel, circle_button, code_editor, code_line, dot, drag_value, frame, horizontal, image, label, left_panel, menu_item, modal, pill, rect_stroke, right, right_panel, scale, screen_size, scroll, select, separator, set_scale, set_text, set_theme, set_widget_layer, shortcut, slider, spacing, text_field, toggle, top_panel, vertical, wants_keyboard
Constants (14):
| Name | Value |
|---|---|
ANCHOR_BOTTOM_LEFT | bottom_left |
ANCHOR_BOTTOM_RIGHT | bottom_right |
ANCHOR_CENTER | center |
ANCHOR_TOP_LEFT | top_left |
ANCHOR_TOP_RIGHT | top_right |
FONT_HEADING | heading |
FONT_MONO | mono |
MOD_ALT | alt |
MOD_CMD | cmd |
MOD_CTRL | ctrl |
MOD_SHIFT | shift |
WIDGET_BUTTON | button |
WIDGET_LABEL | label |
WIDGET_PANEL | panel |