APIReference: Difference between revisions

From Pico-8 Wiki
Jump to navigation Jump to search
imported>Dddaaannn
No edit summary
imported>Dddaaannn
No edit summary
Line 38: Line 38:


* [[Camera|<nowiki>camera([x,] [y])</nowiki>]]
* [[Camera|<nowiki>camera([x,] [y])</nowiki>]]
* [[Circ|<nowiki>circ(x, y, r, [col])</nowiki>]]
* [[Circfill|<nowiki>circfill(x, y, r, [col])</nowiki>]]
* [[Circfill|<nowiki>circfill(x, y, r, [col])</nowiki>]]
* [[Circ|<nowiki>circ(x, y, r, [col])</nowiki>]]
* [[Clip|<nowiki>clip([x,] [y,] [w,] [h])</nowiki>]]
* [[Clip|<nowiki>clip([x,] [y,] [w,] [h])</nowiki>]]
* [[Cls|<nowiki>cls()</nowiki>]]
* [[Cls|<nowiki>cls()</nowiki>]]
Line 47: Line 47:
* [[Fset|<nowiki>fset(n, [f,] [v])</nowiki>]]
* [[Fset|<nowiki>fset(n, [f,] [v])</nowiki>]]
* [[Line|<nowiki>line(x0, y0, x1, y1, [col])</nowiki>]]
* [[Line|<nowiki>line(x0, y0, x1, y1, [col])</nowiki>]]
* [[Pal|<nowiki>pal([c0,] [c1,] [p])</nowiki>]]
* [[Palt|<nowiki>palt([c,] [t])</nowiki>]]
* [[Palt|<nowiki>palt([c,] [t])</nowiki>]]
* [[Pal|<nowiki>pal([c0,] [c1,] [p])</nowiki>]]
* [[Pget|<nowiki>pget(x, y)</nowiki>]]
* [[Pget|<nowiki>pget(x, y)</nowiki>]]
* [[Print|<nowiki>print(str, [x,] [y,] [col])</nowiki>]]
* [[Print|<nowiki>print(str, [x,] [y,] [col])</nowiki>]]
* [[Pset|<nowiki>pset(x, y, [c])</nowiki>]]
* [[Pset|<nowiki>pset(x, y, [c])</nowiki>]]
* [[Rect|<nowiki>rect(x0, y0, x1, y1, [col])</nowiki>]]
* [[Rectfill|<nowiki>rectfill(x0, y0, x1, y1, [col])</nowiki>]]
* [[Rectfill|<nowiki>rectfill(x0, y0, x1, y1, [col])</nowiki>]]
* [[Rect|<nowiki>rect(x0, y0, x1, y1, [col])</nowiki>]]
* [[Sget|<nowiki>sget(x, y)</nowiki>]]
* [[Sget|<nowiki>sget(x, y)</nowiki>]]
* [[Spr|<nowiki>spr(n, x, y, [w,] [h,] [flip_x,] [flip_y])</nowiki>]]
* [[Spr|<nowiki>spr(n, x, y, [w,] [h,] [flip_x,] [flip_y])</nowiki>]]
Line 66: Line 66:
* [[Foreach|<nowiki>foreach(t, f)</nowiki>]]
* [[Foreach|<nowiki>foreach(t, f)</nowiki>]]
* [[Pairs|<nowiki>pairs(t)</nowiki>]]
* [[Pairs|<nowiki>pairs(t)</nowiki>]]
See also [[Lua]], [[Tables]].


== Input ==
== Input ==
Line 111: Line 113:
* [[Sqrt|<nowiki>sqrt(x)</nowiki>]]
* [[Sqrt|<nowiki>sqrt(x)</nowiki>]]
* [[Srand|<nowiki>srand(x)</nowiki>]]
* [[Srand|<nowiki>srand(x)</nowiki>]]
See also [[Math]].


== Cartridge data ==
== Cartridge data ==
Line 129: Line 133:
* [[Setmetatable|<nowiki>setmetatable(tbl, metatbl)</nowiki>]]
* [[Setmetatable|<nowiki>setmetatable(tbl, metatbl)</nowiki>]]
* [[Type|<nowiki>type(v)</nowiki>]]
* [[Type|<nowiki>type(v)</nowiki>]]
* [[Sub|<nowiki>sub(str, from, [to])</nowiki>]]
See also [[Lua]], [[Strings]], [[Tables]], [[Metatables]].
== Time ==
* [[Time|<nowiki>time()</nowiki>]]


== Debugging ==
== Debugging ==

Revision as of 20:10, 11 June 2016

An API is a function provided by Pico-8 that you can call from a cartridge's source code. You can also call API functions from the Pico-8 command prompt, using function syntax.

Calling APIs

Some APIs have optional arguments, indicated in this guide by square brackets around the argument name. To specify a value for an optional argument, you must specify values for all other arguments to the left in the argument list.

For example, the spr() function has three required arguments and four optional arguments:

spr( n, x, y, [w,] [h,] [flip_x,] [flip_y] )

This function can be called with three arguments, accepting the defaults for the others:

spr(1, 60, 60)

To specify a value for the flip_x argument, you must also specify w and h, even if you're using their default values:

spr(1, 60, 60, 1, 1, true)

The game loop

If you define these functions in your code, Pico-8 will call them at specific times. See Game loop.

If your code doesn't use the game loop, you can call this function to copy the graphics buffer to the screen:

Graphics

Tables

See also Lua, Tables.

Input

Sound

Map

Memory

Math

See also Math.

Cartridge data

Coroutines

Values and objects

See also Lua, Strings, Tables, Metatables.

Time

Debugging

See also