Skip to content

Commit 6822939

Browse files
committed
Added script to generate list of snippets and updated readme
1 parent d3feaad commit 6822939

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

README.md

+111
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,117 @@ Currently the plugin provides the following features:
1717

1818
Wherever Pico-8 has an API where there are a "common" set of parameters, and less used optional ones, the snippet for the optional parameters includes the comma, so they can be quickly deleted if not needed, but you will need to type the comma if you want to use them.
1919

20+
## Current Snippets
21+
22+
### audio
23+
* music : Play music (-1 = stop)
24+
* sfx : Play sfx
25+
### basics
26+
* for : Basic for loop
27+
* fors : For loop with step parameter
28+
* forall : For in all loop
29+
* forpair : For in all pairs loop
30+
* while : While loop
31+
* if : Basic if
32+
* iif : Inline if
33+
* ifel : If else
34+
* fun : function
35+
### cart_data
36+
* cartdata : Open cart data (once per exection)
37+
* dget : Get number stored at index (call cartdata first)
38+
* dset : Store value at index (call cartdata first)
39+
### coroutines
40+
* cocreate : Create a coroutine that executes the function
41+
* coresume : Resume a created coroutine, passing optional additional parameters in first time.
42+
* costatus : Get the status of a coroutine, either 'running', 'suspended', or 'dead'.
43+
* yield : Pause execution from within a coroutine.
44+
### graphics
45+
* cam : Set camera position
46+
* circ : Draw a circle
47+
* circf : Draw a filled circle
48+
* clip : Set screen clipping region
49+
* cls : Clear the screen with the given colour
50+
* color : Sets the default drawing colour
51+
* cursor : Set the cursor position and carriage return margin
52+
* fget : Gets the sprite's flag
53+
* fset : Sets the sprite's flag
54+
* flip : Flips the screen back buffer
55+
* line : Draw a line
56+
* pal : Switch colour 0 to colour 1, set palette to 0 for draw palette (sprites etc.), or 1 for screen (fades etc.)
57+
* palt : Sets transparency on given colour to on or off
58+
* pget : Get the value of the pixel at the given coords
59+
* pset : Sets the value of the pixel at the given coords
60+
* print : Prints the string in the given colour at the given coords
61+
* rect : Draws a rectangle outline
62+
* rectfill : Draws a filled rectangle
63+
* sget : Get the spritesheet value of the pixel at the given coords
64+
* sset : Sets the spritesheet value of the pixel at the given coords
65+
* spr : Full draw sprite at given coords with given size and flip flags
66+
* sspr : Draw sprite sheet texture at given coords
67+
* fillp : Set fill pattern for circ, circfill, rect, rectfill, pset, and line (see https://seansleblanc.itch.io/pico-8-fillp-tool)
68+
### input
69+
* btn : Get button state for given player (see pconsts for constants)
70+
* btnp : Get 'repeating' button state for given player (see pconsts for constants)
71+
* dinput : Enable pico8 devkit input for mouse and keyboard input
72+
* dkeyp : (Boolean) True when a key pressed
73+
* dkey : (String) character returned by keyboard
74+
* dmousex : Mouse X
75+
* dmousey : Mouse Y
76+
* dmousebtn : Mouse buttons bitfield
77+
* dmousewheel : Mouse wheel event
78+
### map
79+
* map : Draw the selection of map cells at the given screen position
80+
* mget : Gets the map value of the given cell
81+
* mset : Sets the map value of the given cell
82+
### math
83+
* abs : Abolute value
84+
* atan2 : Converts dx,dy to an angle in the range 0-1
85+
* band : Bitwise AND
86+
* bnot : Bitwise NOT
87+
* bor : Bitwise OR
88+
* bxor : Bitwise XOR
89+
* flr : Round down
90+
* round : Round number
91+
* ceil : Round up
92+
* min : Returns the lowest of the two values
93+
* max : Returns the highest of the two values
94+
* mid : Returns the max, min or middle number e.g. x=mid(min_x, x, max_x) will make sure x is between the min and max values.
95+
* srand : Set random seed for rnd
96+
* rnd : Returns a random number in the range 0-x (remember to round before using for array/sprite indexes!)
97+
* sgn : Returns sign of x e.g. -1 or 1
98+
* shl : Bitwise shift x left n times
99+
* shr : Bitwise shift x right n times
100+
* sin : Sine of x (inverted), returns a value between 0 and 1
101+
* cos : Cosine of x, returns a value between 0 and 1
102+
* sqrt : Square root of x
103+
### memory
104+
* cstore : Copy bytes from ram to filename
105+
* memcpy : Copy memory
106+
* memset : Set memory to value from dest_address for length bytes
107+
* peek : Read byte from RAM
108+
* poke : Write byte to RAM
109+
* reload : Load a section of cartridge into RAM
110+
### peekpoke
111+
* gpiow : Write to GPIO
112+
* gpior : Read from GPIO
113+
* memgfx : Base address for graphics (sprite sheet) memory
114+
* memgfx2 : Base address for graphics/map shared memory
115+
* memmap : Base address for map memory
116+
* memgfxprops : Base address for graphics props memory
117+
* memsong : Base address for song memory
118+
* memsfx : Base address for sfx memory
119+
* memud : Base address for user data memory
120+
* memcd : Base address for persistent cart data memory
121+
* memds : Base address for draw state memory
122+
* memhs : Base address for hardware state memory
123+
* memgpio : Base address for gpio pin memory
124+
* memscr : Base address for screen memory
125+
### pico8
126+
* pheader : Pico8 cartridge header
127+
* game : Basic pico8 game skeleton
128+
* game30 : Basic 30fps pico8 game skeleton
129+
* pconsts : Basic pico8 constants
130+
20131
## Requirements
21132

22133
* VSCode

snippet_docs.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
var output = "";
5+
6+
fs.readdirSync('./snippets/').forEach(file => {
7+
var contents = JSON.parse(fs.readFileSync('./snippets/'+file, 'utf8'));
8+
9+
var sectionName = path.basename(file, ".json");
10+
11+
output += "### " + sectionName + "\n";
12+
13+
var values = Object.values(contents);
14+
15+
values.forEach(snip => {
16+
output += "* " + snip.prefix + " : " + snip.description + "\n";
17+
});
18+
19+
});
20+
21+
console.log(output);

0 commit comments

Comments
 (0)