Commandline 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 coordinates 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 |
splore |
Boot in splore mode |
home path |
Set the path to store config.txt and other user data files |
desktop path |
Set a location for screenshots and gifs to be saved |
screenshot_scale n |
Scale of screenshots. 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) |
software_blit n |
Use software blitting mode off (0) or on (1) |
foreground_sleep_ms n |
How many milliseconds to sleep between frames |
background_sleep_ms n |
How many milliseconds to sleep between frames when running in background |
these override settings found in config.txt
Screenshots, Videos and Cartridge Labels
F6 |
Save a screenshot to desktop |
F7 |
Capture cartridge label image |
F8 |
Start recording a video |
F9 |
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 recording). Use F8 just to reset
the video starting point if you want something less than 8 seconds long
Graphics
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 spritesheet pixel |
sset x y [c] |
Set the colour (c) of a spritesheet 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 transparency for colour index to t (boolean) |
Transparency 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
Tables
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 |
FOR V IN ALL(T) DO PRINT(V) END |
foreach t f |
For each item in table t, call function f with the item as a single parameter |
FOREACH(T, PRINT) |
pairs t |
Used in FOR loops to iterate over table t, providing both the key and value for each item |
Input
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 keyboard-style repeating |
i is the button number
p is the player number
Audio
sfx n [channel [offset [length]]] |
Plays a sound effect n |
music [n [fade_len [channel_mask]]] |
Plays a music pattern, or stops playing |
Map
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) |
Math
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 "floor") of a number |
ceil x |
Returns the next highest integer (the "ceiling") 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 |
Initializes the random number generator with an explicit seed value |
Angle x measured clockwise and is between 0.0 .. 1.0
Strings
length |
|
print(#s) --> 19 |
joining strings |
|
print("three "..4) --> "three 4" |
sub() to grab substrings |
|
print(sub(s,5,9)) --> "quick" |
s = "the quick brown fox"
Types
type val |
Returns the basic type of a given value as a string |
print(type(1)) -- "number" |
tostr val [hex] |
Converts a non-string value to a string representation |
s = 'v: '..tostr(12345) -- 'v: 12345' |
tonum val |
Converts a string representation of a decimal, hexadecimal, or binary number to a number value |
hex - if hex is true and val is a number, an unsigned hexadecimal writing of the number is returned in the format "0x0000.0000"
Binary Operations
band x y |
Calculates the bitwise AND of two numbers |
print(band(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(bxor(0x5, 0x9)) -- 12 (0xc) |
bnot x |
Calculates the bitwise NOT of a number |
print(bnot(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(rotr(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 |
Coroutines
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 coroutine's function |
Returns true if the coroutine completes without any errors |
costatus c |
Return the status of coroutine c as a string |
"running", "suspended", "dead" |
yield |
Suspend execution and return to the caller |
assert( cond, [message] ) |
Causes a runtime error if a conditional expression is false |
stop( [message,] [x,] [y,] [c] ) |
Stops the program's execution and returns to the command prompt |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by Zoltan