Skip to content

Latest commit

 

History

History
64 lines (54 loc) · 4.31 KB

File metadata and controls

64 lines (54 loc) · 4.31 KB

CursorScript API

Welcome to the CursorScript API documentation. This index provides links to detailed documentation for each library and core language feature.

Core Language Features

Built-in Libraries



Global Functions Quick Reference

Function Description Example
print(args...) Prints values to the console. print("Hello", 42);
printError(...) Prints values to the error console (red). printError("Fetch failed!");
time() Returns the current time in milliseconds. let start = time();
rand(min, max) Returns a random integer between min and max (inclusive). let n = rand(1, 10);
len(val) Returns the length of a string or array. len("hello"); // 5
push(arr, v) Appends a value to the end of an array. push(myArr, 10);
pop(arr) Removes and returns the last element of an array. let last = pop(myArr);
shift(arr) Removes and returns the first element of an array. let first = shift(myArr);
unshift(arr, v) Prepends a value to the start of an array. unshift(myArr, 0);
str(val) Converts a value to its string representation. let s = str(123);
typeof(val) Returns the type of a value as a string. let t = typeof(10); // "number"
concat(args...) Concatenates values into a single string with spaces. concat("foo", "bar"); // "foo bar"
exit() Exits the program with code 1. exit();
clear() Clears the console. clear();
help() Prints help information to the console. help();
wait(ms) Asynchronously pauses execution for ms milliseconds. await wait(1000);