Skip to main content

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.

ModuleFunctionsConstantsAvailable in
audio20every language
engine50every language
fs40every language
input9165every language
log50every language
node280every language
physics125every language
physics2d95every language
render220every language
rng40every language
scene70every language
toml20every language
ui3814every 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):

NameValue
KEY_0Key0
KEY_1Key1
KEY_2Key2
KEY_3Key3
KEY_4Key4
KEY_5Key5
KEY_6Key6
KEY_7Key7
KEY_8Key8
KEY_9Key9
KEY_AA
KEY_ABNT_C1AbntC1
KEY_ABNT_C2AbntC2
KEY_ADDAdd
KEY_APOSTROPHEApostrophe
KEY_APPSApps
KEY_ATAt
KEY_AXAx
KEY_BB
KEY_BACKBack
KEY_BACKSLASHBackslash
KEY_CC
KEY_CALCULATORCalculator
KEY_CAPITALCapital

…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):

NameValue
BODY_DYNAMICdynamic
BODY_KINEMATICkinematic
BODY_STATICstatic
SHAPE_BALLball
SHAPE_CUBOIDcuboid

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):

NameValue
BODY_DYNAMICdynamic
BODY_KINEMATICkinematic
BODY_STATICstatic
SHAPE_CIRCLEcircle
SHAPE_RECTrect

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):

NameValue
ANCHOR_BOTTOM_LEFTbottom_left
ANCHOR_BOTTOM_RIGHTbottom_right
ANCHOR_CENTERcenter
ANCHOR_TOP_LEFTtop_left
ANCHOR_TOP_RIGHTtop_right
FONT_HEADINGheading
FONT_MONOmono
MOD_ALTalt
MOD_CMDcmd
MOD_CTRLctrl
MOD_SHIFTshift
WIDGET_BUTTONbutton
WIDGET_LABELlabel
WIDGET_PANELpanel