cameronism [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=25378 luacheck configuration file <p>I've found <a href="https://github.com/mpeterv/luacheck">luacheck</a> useful when writing lua. It is very much like <a href="http://jshint.com">JSHint</a> for JavaScript and other static analysis tools in general. Luacheck finds usage of undefined global variables, unused variables and values, accessing uninitialized variables, unreachable code, etc.</p> <p>Here is a <a href="https://gist.github.com/cameronism/cbf31bfbb9d451ab1a9e8b244f6b3e9d">Gist of my pico-8 .luacheckrc</a>, I keep it in the parent directory of my pico-8 files. I also use <a href="https://github.com/dansanderson/picotool">p8tool</a> so I can work on lua files directly.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre> std = { -- these globals can be set and accessed. globals = { &quot;_init&quot;, &quot;_draw&quot;, &quot;_update&quot;, &quot;_update60&quot; }, -- these globals can only be accessed. read_globals = { --[[ copy( `-- from ${location.href} ${(new Date()).toISOString()}\n` + [].slice.call($('#WikiaMainContent').find('ul&gt;li&gt;a,.mw-headline')) .map(a =&gt; a.tagName == 'A' ? `'${a.innerText.replace(/\(.*/g,'')}', -- ${a.innerText.trim()}` : `\n-- ${a.innerText.trim()}`).join('\n')) ]] -- from http://pico-8.wikia.com/wiki/APIReference 2017-08-12T17:14:36.282Z -- The game loop 'flip', -- flip() -- Graphics 'camera', -- camera([x,] [y]) 'circ', -- circ(x, y, r, [col]) 'circfill', -- circfill(x, y, r, [col]) 'clip', -- clip([x,] [y,] [w,] [h]) 'cls', -- cls() 'color', -- color(col) 'cursor', -- cursor(x, y) 'fget', -- fget(n, [f]) 'fset', -- fset(n, [f,] [v]) 'line', -- line(x0, y0, x1, y1, [col]) 'pal', -- pal([c0,] [c1,] [p]) 'palt', -- palt([c,] [t]) 'pget', -- pget(x, y) 'print', -- print(str, [x,] [y,] [col]) 'pset', -- pset(x, y, [c]) 'rect', -- rect(x0, y0, x1, y1, [col]) 'rectfill', -- rectfill(x0, y0, x1, y1, [col]) 'sget', -- sget(x, y) 'spr', -- spr(n, x, y, [w,] [h,] [flip_x,] [flip_y]) 'sset', -- sset(x, y, [c]) 'sspr', -- sspr(sx, sy, sw, sh, dx, dy, [dw,] [dh,] [flip_x,] [flip_y]) -- Tables 'add', -- add(t, v) 'all', -- all(t) 'del', -- del(t, v) 'foreach', -- foreach(t, f) 'pairs', -- pairs(t) -- Input 'btn', -- btn([i,] [p]) 'btnp', -- btnp([i,] [p]) -- Sound 'music', -- music([n,] [fade_len,] [channel_mask]) 'sfx', -- sfx(n, [channel,] [offset]) -- Map 'map', -- map(cel_x, cel_y, sx, sy, cel_w, cel_h, [layer]) 'mget', -- mget(x, y) 'mset', -- mset(x, y, v) -- Memory 'cstore', -- cstore(dest_addr, source_addr, len, [filename]) 'memcpy', -- memcpy(dest_addr, source_addr, len) 'memset', -- memset(dest_addr, val, len) 'peek', -- peek(addr) 'poke', -- poke(addr, val) 'reload', -- reload(dest_addr, source_addr, len, [filename]) -- Math 'abs', -- abs(x) 'atan2', -- atan2(dx, dy) 'band', -- band(x, y) 'bnot', -- bnot(x) 'bor', -- bor(x, y) 'bxor', -- bxor(x, y, ) 'cos', -- cos(x) 'flr', -- flr(x) 'max', -- max(x, y) 'mid', -- mid(x, y, z) 'min', -- min(x, y) 'rnd', -- rnd(x) 'shl', -- shl(x, y) 'shr', -- shr(x, y) 'sin', -- sin(x) 'sqrt', -- sqrt(x) 'srand', -- srand(x) -- Cartridge data 'cartdata', -- cartdata(id) 'dget', -- dget(index) 'dset', -- dset(index, value) -- Coroutines 'cocreate', -- cocreate(func) 'coresume', -- coresume(cor) 'costatus', -- costatus(cor) 'yield', -- yield() -- Values and objects 'setmetatable', -- setmetatable(tbl, metatbl) 'type', -- type(v) 'sub', -- sub(str, from, [to]) -- Time 'time', -- time() -- System 'menuitem', -- menuitem(index, [label, callback]) -- Debugging 'assert', -- assert(expr) 'printh', -- printh(str, [filename], [overwrite]) 'stat', -- stat(n) 'stop', -- stop() 'trace', -- trace() } } </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> https://www.lexaloffle.com/bbs/?tid=29778 https://www.lexaloffle.com/bbs/?tid=29778 Sat, 12 Aug 2017 13:57:02 UTC