CatpileDocs
Language Reference

Actions

Actions are the building blocks of CatLang — they map directly to CatWeb action IDs. Every action has a name, takes typed arguments, and may return output variables.

#
python
action_name(arg1, arg2)
output = action_name(arg1)
out1, out2 = action_name(arg1)
#

Logging and debugging output.

CatLangSchema NameIDDescription
log(msg)LOG0Print to console
warn(msg)WARN1Print warning
error(msg)ERROR2Print error
comment(text)COMMENT124No-op comment in action list
python
log("Hello world")
warn(l_score)
error("Something broke")
comment("TODO: optimize this")
#

Conditions, comparisons, and flow control.

CatLangSchema NameIDDescription
wait(seconds)WAIT3Pause execution
if eq(a, b):IF_EQ18If equal
if neq(a, b):IF_NEQ19If not equal
if gt(a, b):IF_GT20If greater than
if lt(a, b):IF_LT21If lower than
if gte(a, b):IF_GTE125If greater or equal
if lte(a, b):IF_LTE126If lower or equal
if contains(str, substr):IF_CONTAINS37If string contains
if not_contains(str, substr):IF_NOT_CONTAINS38If doesn't contain
if and(a, b):IF_AND44Logical AND
if or(a, b):IF_OR45Logical OR
if nor(a, b):IF_NOR46Logical NOR
if xor(a, b):IF_XOR47Logical XOR
if exists(var):IF_EXISTS92If variable exists
if not_exists(var):IF_NOT_EXISTS93If doesn't exist
if mouse_left:IF_MOUSE_LEFT79Left mouse button down
if mouse_middle:IF_MOUSE_MIDDLE80Middle mouse button down
if mouse_right:IF_MOUSE_RIGHT81Right mouse button down
if key_down(key):IF_KEY_DOWN82Key held down
if is_ancestor(a, b):IF_IS_ANCESTOR103If ancestor of
if is_child(a, b):IF_IS_CHILD104If child of
if is_descendant(a, b):IF_IS_DESCENDANT105If descendant of
if dark_theme:IF_DARK_THEME108Dark mode enabled
python
if eq(l_score, 100):
    log("Perfect")

if exists(l_player):
    log("Player exists")

if key_down("Shift"):
    log("Sprinting")

wait(0.5)
#

Repeated execution and iteration.

CatLangSchema NameIDDescription
repeat(n):REPEAT22Repeat n times
repeat_forever:REPEAT_FOREVER23Loop indefinitely
foreach(table):TABLE_ITER113Iterate over table
breakBREAK24Exit loop
python
repeat(10):
    inc(l_count, 1)

repeat_forever:
    if gt(l_lives, 0):
        wait(1)
    else:
        break

foreach(l_items):
    log("{l_index}: {l_value}")

foreach automatically provides l_index (key) and l_value (value) variables.

#

UI element visibility, text, properties, and images.

CatLangSchema NameIDDescription
show(target)LOOK_SHOW9Make visible
hide(target)LOOK_HIDE8Make invisible
set_text(target, text)LOOK_SET_TEXT10Set text content
set_prop(prop, target, value)LOOK_SET_PROP31Set element property
get_prop(prop, target)valueLOOK_GET_PROP39Get element property
duplicate(target)cloneLOOK_DUPLICATE49Clone element
delete(target)LOOK_DELETE50Destroy element
set_image(target, id)LOOK_SET_IMG106Set image
set_avatar(target, userid, res?)LOOK_SET_AVATAR107Set to avatar image
tween(prop, target, value, time, style, dir)LOOK_TWEEN88Animate property
get_at_pos(x, y)arrayLOOK_GET_AT_POS127Get objects at position
get_asset_info(info, id)valueLOOK_GET_ASSET_INFO129Get asset metadata
python
hide(page.LoadingScreen)
show("gameArea")
set_text(l_label, "Score: 100")
set_prop("Background Color", l_frame, Colors.navy)
l_bg = get_prop("Background Color", l_frame)
l_clone = duplicate(page.Template)
tween("Position", l_box, "0,200", 0.5, "Quad", "Out")
#

Element tree navigation and reparenting.

CatLangSchema NameIDDescription
parent(child, new_parent)HIER_PARENT58Reparent element
get_parent(child)parentHIER_GET_PARENT97Get parent element
find_ancestor(name, obj)ancestorHIER_FIND_ANCESTOR98Find ancestor by name
find_child(name, parent)childHIER_FIND_CHILD99Find child by name
find_descendant(name, parent)descHIER_FIND_DESCENDANT100Find descendant by name
get_children(parent)tableHIER_GET_CHILDREN101Get all children
get_descendants(parent)tableHIER_GET_DESCENDANTS102Get all descendants
python
parent(l_drag, l_dropZone)
l_root = get_parent(l_child)
l_btn = find_child("SubmitBtn", l_form)
l_all = get_children(l_container)
#

Variable arithmetic, rounding, and math functions.

CatLangSchema NameIDDescription
set(var, value)VAR_SET11Set variable
inc(var, amount)VAR_INC12Increment
dec(var, amount)VAR_DEC13Decrement
mul(var, factor)VAR_MUL14Multiply
div(var, divisor)VAR_DIV15Divide
mod(var, divisor)VAR_MOD41Modulo
pow(var, exponent)VAR_POW40Raise to power
round(var)VAR_ROUND16Round to nearest
floor(var)VAR_FLOOR17Round down
ceil(var)VAR_CEIL78Round up
random(var, min, max)VAR_RANDOM27Random number
del(var)VAR_DEL96Delete variable
set_attr(prop, var, value)AVAR_SET94Set attribute on variable
get_attr(prop, var)valueAVAR_GET95Get attribute of variable
math_run(func, args...)resultMATH_RUN114Run math function
python
set(l_score, 0)
inc(l_score, 10)
mul(l_score, 2)
div(l_score, 100)
random(l_damage, 1, 20)
floor(l_avg)
l_result = math_run("sqrt", 144)
#

Playback control for sounds and music.

CatLangSchema NameIDDescription
play_audio(id)variableAUDIO_PLAY5Play audio once
play_audio_loop(id)variableAUDIO_PLAY_LOOP26Play looped audio
stop_all_audio()AUDIO_STOP_ALL7Stop all sounds
stop_audio(variable)AUDIO_STOP74Stop specific audio
pause_audio(variable)AUDIO_PAUSE75Pause audio
resume_audio(variable)AUDIO_RESUME76Resume audio
set_volume(variable, vol)AUDIO_SET_VOL73Set volume (0-1)
set_speed(variable, speed)AUDIO_SET_SPEED77Set playback speed
python
l_music = play_audio("rbxassetid://12345")
play_audio_loop("rbxassetid://67890")
set_volume(l_music, 0.5)
pause_audio(l_music)
#

User input and viewport information.

CatLangSchema NameIDDescription
get_text(input)textINPUT_GET_TEXT30Get text from input field
get_viewport()w, hINPUT_GET_VIEWPORT84Get viewport dimensions
get_cursor()x, yINPUT_GET_CURSOR85Get cursor position
get_username()nameUSER_GET_NAME51Get local username
get_user_id()idUSER_GET_ID52Get local user ID
get_display_name()nameUSER_GET_DISPLAY53Get display name
python
l_input = get_text(page.NameField)
l_w, l_h = get_viewport()
l_x, l_y = get_cursor()
l_user = get_username()
#

Broadcasting and messaging across the page, site, or cross-site.

CatLangSchema NameIDDescription
broadcast_page(message)NET_BROADCAST_PAGE32Broadcast across page
broadcast_site(message)NET_BROADCAST_SITE33Broadcast across site
broadcast_crosssite(message, url)NET_BROADCAST_CROSSSITE130Broadcast to another page
python
broadcast_page("player_joined")
broadcast_site("score_updated")
broadcast_crosssite("item_purchased", "https://example.com/shop")
#

Persistent key-value storage.

CatLangSchema NameIDDescription
set_cookie(name, value)COOKIE_SET34Set cookie
inc_cookie(name, amount)COOKIE_INC35Increment cookie
get_cookie(name)valueCOOKIE_GET36Get cookie
del_cookie(name)COOKIE_DEL62Delete cookie
python
set_cookie("highscore", 5000)
l_score = get_cookie("highscore")
inc_cookie("visits", 1)
del_cookie("temp_data")
#

Timestamps, formatting, and server time.

CatLangSchema NameIDDescription
get_unix()timestampTIME_GET_UNIX68Get local unix timestamp
get_server_unix()timestampTIME_GET_SERVER_UNIX116Get server unix timestamp
get_tick()tickTIME_GET_TICK83Get tick count
get_timezone()tzTIME_GET_TIMEZONE118Get timezone
format_now(format)strTIME_FORMAT_NOW71Format current date/time
format_unix(ts, format)strTIME_FORMAT_UNIX72Format from unix timestamp
python
l_now = get_unix()
l_date = format_now("%Y-%m-%d")
l_formatted = format_unix(l_timestamp, "%H:%M:%S")
l_tz = get_timezone()
#

Color space conversion and interpolation.

CatLangSchema NameIDDescription
hex_to_rgb(hex)RGBCOLOR_HEX_TO_RGB119Hex to RGB string
hex_to_hsv(hex)HSVCOLOR_HEX_TO_HSV120Hex to HSV string
rgb_to_hex(RGB)hexCOLOR_RGB_TO_HEX121RGB to hex
hsv_to_hex(HSV)hexCOLOR_HSV_TO_HEX122HSV to hex
lerp_color(hex1, hex2, alpha)hexCOLOR_LERP123Interpolate between colors
python
l_rgb = hex_to_rgb("#1a1a2e")
l_hex = rgb_to_hex("255, 128, 64")
l_mid = lerp_color("#ff0000", "#0000ff", 0.5)
#

String manipulation and inspection.

CatLangSchema NameIDDescription
str_len(str)lengthSTR_LEN48Get string length
str_sub(var, start, end)resultSTR_SUB42Substring
str_replace(old, var, new)resultSTR_REPLACE43Replace substring
str_split(str, sep)tableSTR_SPLIT57Split into table
str_lower(str)resultSTR_LOWER69Convert to lowercase
str_upper(str)resultSTR_UPPER70Convert to uppercase
str_concat(a, b)resultSTR_CONCAT109Concatenate two strings
python
l_len = str_len("hello")
l_greeting = str_concat("Hello, ", l_name)
l_parts = str_split("a,b,c", ",")
l_lower = str_lower("HELLO")
l_sub = str_sub(l_text, 0, 5)

String interpolation "Hello {name}!" is syntax sugar that compiles to STR_CONCAT chains automatically.

#

Dictionary and array operations.

CatLangSchema NameIDDescription
create_table(name)TABLE_CREATE54Create empty table
table_set(entry, table, value)TABLE_SET55Set entry by key
table_set_obj(entry, table, obj)TABLE_SET_OBJ66Set entry to object
table_get(entry, table)valueTABLE_GET56Get entry by key
table_del(entry, table)TABLE_DEL90Delete entry by key
table_insert(value, pos?, array)TABLE_INSERT89Insert into array
table_remove(pos, array)TABLE_REMOVE91Remove at position
table_len(array)lengthTABLE_LEN59Get array length
table_join(array, sep)stringTABLE_JOIN110Join array to string
python
create_table(l_settings)
table_set("volume", l_settings, 0.8)
l_vol = table_get("volume", l_settings)
table_insert("new_item", 1, l_list)
table_remove(1, l_list)
l_count = table_len(l_list)
l_csv = table_join(l_list, ",")

Dict literals {"key": value} compile to TABLE_CREATE + TABLE_SET chains automatically.

#

Defining and calling reusable logic.

CatLangSchema NameIDDescription
func_run(name, args...)resultFUNC_RUN87Run function synchronously
func_run_bg(name, args...)FUNC_RUN_BG63Run function in background
func_run_protected(name, args...)success, resultFUNC_RUN_PROTECTED128Run protected (pcall-style)
return valueRETURN115Return from function
python
l_result = func_run("add", 5, 3)
func_run_bg("save_data", l_payload)
l_ok, l_data = func_run_protected("load", "file.json")

func_run_protected returns success as the first output and the actual result as the second.