Show Menu

Comman­dline Parameters

width n
Set the window width
height n
Set the window height
windowed n
Set windowed mode off (0) or on (1)
sound n
Sound volume 0..256
music n
Music volume 0..256
joystick n
Joystick controls starts at player n (0..7)
pixel_­perfect n
1 for unfiltered screen stretching at integer scales (on by default)
draw_rect x,y,w,h
Absolute window coordi­nates and size to draw pico-8's screen
run filename
Load and run a cartridge
x filename
Execute a pico-8 cart headless and then quit
p param_str
Pass a parameter string to the specified cartridge
Boot in splore mode
home path
Set the path to store config.txt and other user data files
desktop path
Set a location for screen­shots and gifs to be saved
screen­sho­t_scale n
Scale of screen­shots. default: 3 (368x368 pixels)
gif_scale n
Scale of gif captures. default: 2 (256x256 pixels)
gif_len n
Set the maximum gif length in seconds (1..120)
gui_theme n
Use 1 for a higher contrast editor colour scheme
timeout n
How many seconds to wait before downloads timeout (default: 30)
softwa­re_blit n
Use software blitting mode off (0) or on (1)
foregr­oun­d_s­leep_ms n
How many millis­econds to sleep between frames
backgr­oun­d_s­leep_ms n
How many millis­econds to sleep between frames when running in background
these override settings found in config.txt

Screen­shots, Videos and Cartridge Labels

Save a screenshot to desktop
Capture cartridge label image
Start recording a video
Save GIF video to desktop (max: 8 seconds by default)
-if F6..F9 are not available on your system, use CTRL-6..9
-You can save a video at any time (it is always record­ing). Use F8 just to reset
the video starting point if you want something less than 8 seconds long


clip [x y w h]
Sets the screen's clipping region in pixels clip() to reset
pget x y
Get the colour (c) of a pixel at x, y
pset x y [c]
Set the colour (c) of a pixel at x, y
sget x y
Get the colour (c) of a sprite­sheet pixel
sset x y [c]
Set the colour (c) of a sprite­sheet pixel
fget n [f]
Get the value (v) of a sprite's flag
fset n [f] v
Set the value (v) of a sprite's flag
print( str, [x,] [y,] [c] )
Prints a string of characters to the screen
cursor x y
Set the cursor position and carriage return margin
color c
Set the default color to be used by drawing functions
cls [c]
Clear the screen and reset the clipping rectangle
c is the background color. The default is 0 (black).
camera [x y]
Set a screen offset of -x, -y for all drawing operations
camera() to reset
circ x y r [c]
Draw a circle at x,y with radius r
circfill x y r [col]
Draw a filled circle at x,y with radius r
line x0 y0 x1 y1 [c]
Draw a line
rect x0 y0 x1 y1 [c]
Draw a rectangle
rectfill x0 y0 x1 y1 [c]
Draw a filled rectangle
pal c0 c1 [p] (1)
Draw all instances of colour c0 as c1 in subsequent draw calls
pal() to reset to system defaults
palt c t
Set transp­arency for colour index to t (boolean)
Transp­arency is observed by spr(), sspr() and map()
spr n x y [w h] [flip_x] [flip_y]
Draw sprite n at position x,y,width and height are 1,1 by default
sspr sx sy sw sh dx dy [dw dh] [flip_x] [flip_y]
Draws a rectangle of pixels from the sprite sheet, optionally stretching the image to fit a rectangle on the screen
fillp p
Sets the fill pattern, observed by: circ() circfill() rect() rectfill() pset() line()
params in [] are optional
f is the flag index 0..7
v is boolean and can be true or false
c is color
(1) Two types of palette (p defaults to 0)
0 draw palette, colours are remapped on draw //e.g to re-colour sprites
1 screen palette, colours are remapped on display //e.g for fades


add t v
Add value v to the end of table t
del t v
Delete the first instance of value v in table t
all t
Used in FOR loops to iterate over all items in a table
foreach t f
For each item in table t, call function f with the item as a single parameter
pairs t
Used in FOR loops to iterate over table t, providing both the key and value for each item


btn [i [p]]
Tests if a button is being pressed at this moment
btnp [i [p]]
Tests if a button has just been pressed, with keyboa­rd-­style repeating
i is the button number
p is the player number


sfx n [channel [offset [length]]]
Plays a sound effect n
music [n [fade_len [chann­el_­mask]]]
Plays a music pattern, or stops playing


mget x y
Gets the sprite number assigned to a cell on the map
mset x y v
Sets a cell on the map to a new sprite number
map cel_x cel_y sx sy cel_w cel_h [layer]
Draw a section of the map (in cels) at screen position sx, sy (in pixels)


max x y
Returns the maximum of two numbers
min x y
Returns the minimum of two numbers
mid x y z
Returns the middle of three numbers
flr x
Returns the integer portion (the "­flo­or") of a number
ceil x
Returns the next highest integer (the "­cei­lin­g") of a number
cos x
Calculates the cosine of an angle
sin x
Calculates the sine of an angle
atan2 dx dy
Converts dx, dy into an angle from 0..1
sqrt x
Calculates the square root of a number
abs x
Returns the absolute value of a number
rnd x
Generates a random number between 0 and the given maximum
srand x
Initia­lizes the random number generator with an explicit seed value
Angle x measured clockwise and is between 0.0 .. 1.0


print(#s) --> 19
joining strings
print(­"­three "..4) --> "­three 4"
sub() to grab substrings
print(­sub­(s,­5,9)) --> "­qui­ck"
s = "the quick brown fox"


type val
Returns the basic type of a given value as a string
print(­typ­e(1)) -- "­num­ber­"
tostr val [hex]
Converts a non-string value to a string repres­ent­ation
s = 'v: '..tos­tr(­12345) -- 'v: 12345'
tonum val
Converts a string repres­ent­ation of a decimal, hexade­cimal, or binary number to a number value
hex - if hex is true and val is a number, an unsigned hexade­cimal writing of the number is returned in the format "­0x0­000.00­00"

Binary Operations

band x y
Calculates the bitwise AND of two numbers
print(­ban­d(0x7, 0xd)) -- 5
bor x y
Calculates the bitwise OR of two numbers
print(­bor­(0x5, 0x9)) -- 13 (0xd)
bxor x y
Calculates the bitwise XOR of two numbers
print(­bxo­r(0x5, 0x9)) -- 12 (0xc)
bnot x
Calculates the bitwise NOT of a number
print(­bno­t(0xb)) -- -11 (0 - 0xb)
rotl x y
Rotates the bits of a number to the left
print(­rotl(8, 3)) -- 64
rotr x y
Rotates the bits of a number to the right
print(­rot­r(64, 3)) -- 8
shl x n
Shifts the bits of a number to the left
print(­shl(1, 3)) -- 8
shr x n
Shifts the bits of a number to the right
print(­shr(8, 3)) -- 1
lshr x n
Shifts the bits of a number to the right, using logical shift
print(­lshr(8, 3)) -- 1


cocreate f
Create a coroutine for function f
coresume c [p0 p1 ..]
Run or continue the coroutine c. Parameters p0, p1.. are passed to the corout­ine's function
Returns true if the coroutine completes without any errors
costatus c
Return the status of coroutine c as a string
"­run­nin­g", "­sus­pen­ded­", "­dea­d"
Suspend execution and return to the caller
assert( cond, [message] )
Causes a runtime error if a condit­ional expression is false
stop( [message,] [x,] [y,] [c] )
Stops the program's execution and returns to the command prompt


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Roblox: General Scripting Cheat Sheet
          Roblox: CFrames Cheat Sheet

          More Cheat Sheets by Zoltan

          Basic Vim Cheat Sheet