Log In  

New API pack() returns a table with an "n" field of always 0?

?pack(1,2).n -- 0 (expected: 2)
?pack(1,2,nil,3,nil).n -- 0 (expected: 5)

table.pack works as expected in lua.

P#76239 2020-05-09 15:53

I've just seen from the Pico 8 wiki that there's a new while shorthand:
while (cond) actions

And yeah - it works.
But it's not documented anywhere in the manual - not in the shorthand section and not even in the changelog!

P#75025 2020-04-20 06:39

(Applies to verison 0.1.12d rcsd)

  1. Lua's 'tostring' function is exposed now. It converts things to strings differently than tostr, including printing a table's address in memory.

  2. After doing "install_demos()" or "install_games()", something seems to go majorly wrong with pico-8. All nils become... nulls?!
    You can see this by trying to print a non-existing global/table value which would normally print [nil], but now prints [(null)].
    What is the type of a null? It's a null, too! (No, not the string "null" - but a null object itself)
    (It's clearly not a legal lua value)

You can see the above oddities via my https://www.lexaloffle.com/bbs/?tid=36381 cart, if you'd like.

P#71448 2019-12-28 02:32 ( Edited 2019-12-28 09:11)

Cart #pico_repl-25 | 2021-02-12 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

What's this?

A REPL (Read-Eval-Print Loop) for pico-8, in pico-8!

Supports executing most all lua & pico-8 statements. (if statements, for loops, functions - you name it)

While my code does its own parsing and execution of the statements, any functions you call are the real pico-8 functions.

What can I do with it?

Type expressions like 1+3/5 or sqrt(-2) to see the expected results. (Well - perhaps unexpected to some in the case of the sqrt)

Type statements or programs like the one below to do whatever you wish. (That one prints all global functions)

for k, v in pairs(_env) do
  if (type(v) == "function") ?k

Computations that produce lots of results are automatically paged, computations that do nothing indefinitely can be interrupted via escape (escape works in BBS or SPLORE only)

The special variable "_" is set to the value of the last expression you've executed.

The special variable "_env" points to the globals table (just like "_ENV" in standard lua/pico-8, just lower-case, making it easier to type)

Pico-8's globals are not disturbed and are the same as in a blank Pico-8 cart.

You can type "\i=0" to disable all text that "interrupts" the code while its executing, letting the code use up the entire screen. This also disables output paging, but pressing escape to stop execution still works.

What's the point of this? Pico-8 has a REPL already!

The main point of it is that I made it, everything else is up to you.

But for example, you can easily take a look at whatever Pico version happens to be running in the BBS, and see how it differs from your own.

Can I use this to write Pico-8 carts?

No. All this allows you to do is to write and execute some code.

You can't edit sprites/sfx/etc/etc, or export, or import, etc etc etc.

Hopefully that's limited enough to avoid running afoul of any legal concerns.

What are the caveats?

As said, all evaluation other than execution of global functions is implemented by me and may have bugs (feel free to report those), or subtle inconsistencies with real pico8/lua behaviour.

No bugs or missing features are currently known.

How do I copy code into the interpreter?

BBS now supports copy/paste, so it's easy - just use Ctrl+V to paste and Ctrl+X/C to cut/copy.

Well - cut/copy is currently a bit janky on the BBS - you have to press it twice to get it on the clipboard.

Outside the BBS, Ctrl+V still works, but Ctrl+X/C will only work once 0.1.12d hits (most likely).

The below hidden section is here for historical reasons, to show how one could have laboriously pasted into the BBS without paste support.

  1. Open your browser's console. (Press Ctrl+Shift+I or F12, then switch to Console tab)
  2. Paste "pico8_gpio = new TextEncoder().encode(``)" into the browser's console
  3. Between the two backquotes (`), paste the code you want to transfer to the cart.
  4. Press enter, the first 128 bytes will now be transferred - you should see them appear in the cart.
  5. Paste "pico8_gpio = pico8_gpio.slice(0x80)" into the browser's console.
  6. Press enter, the next 128 bytes will be transferred.
  7. Goto step 5 until all the code is transferred.

Anything else of interest?

There are some special \-prefixed identifiers which act like special variables:

  • \interrupt (or \i) : set this to 0 to disable anything that might interfere with the running code (e.g. prompts while running code, override of print function, etc.) (default: 1)
  • \flip (or \f) : set this to 0 to disable auto-flipping. Requires \i to be 0 to have any effect. Useful for code that does its own flips but runs too slow under the REPL. (default: 1)
  • \code (or \c) : a table of the most recently input code (item 1 is the previous code, item 2 is the one before it, and so on. item 0 is the current code). You can use this to store the code you've typed somewhere, e.g. printh(\c[1], "@clip")
  • \max_items (or \mi) : the maximal number of items shown when printing a table. -1 means show all. (default: 10)
  • \hex (or \h) : if true, numbers are printed in hex. (default: false)
  • \colors (or \cl) : a table of the colors used, customization! color meaning: {output, errors, interrupts, prompt, input, input errors, comments, constants, keywords, punctuation, pico functions}

As well as some special \-prefixed functions:

  • \exec (or \x) : a function that takes a string, and executes the string as if it were written in the repl's command line.
  • \eval (or \v) : a function that takes a string, and evaluates the string as a lua expression (with the full power of the repl), returning its result.

And even some special \-prefixed commands (identifiers which perform an action when accessed):

  • \reset (or \rst) : completely resets the cart
  • \run : if _draw/_update/etc were defined, runs them as if from the pico mainloop (not fully compatible)

And some shortcuts:

  • Ctrl+X/C/V - cut/copy/paste.
  • Ctrl+B - insert a line-break. (in lieu of shift+enter...)
  • Ctrl+A/E - move cursor to start/end of line (in lieu of home/end...)


That's not a question.
I mean:


  • Proper support for _env reassignment/redeclaration, just for completion's sake.


  • Fixed keyboard input. (stat(30) and stat(31))
  • Fixed output for code that prints something and then hangs for a while.
  • Added "\f=0" to disable auto-flip (also requires "\i=0")


  • Faster trailing-nil handling using new Pico8 APIs.
  • Self-test on startup. (Will give an error if there's a regression again)
  • Fixed \eval for tail calls


  • Fixed for regression introduced in Pico v0.2.1


  • Updated for changed Pico v0.2.0f opcodes. (Now requires v0.2.0f and up)


  • Fixed for Pico v0.2.0e (no longer relying on pico8's coroutine bug)


  • Added new Pico v0.2.0d opcodes. (Now requires v0.2.0d and up)
  • Added v0.2.0 while shorthand


  • Added new Pico v0.2.0 opcodes. (Now requires Pico8 v0.2.0 and up)
  • Changed all @-prefixed identifiers/commands to be \-prefixed instead, now that pico8 stole @ from me.
  • Added \hex


  • Fixed editing of large inputs


  • Added \exec & \eval


  • Fully working trailing-nil handling. (Thanks to JWinslow23 & sparr for ideas in the discord)


  • Ctrl+A/E as a poor linuxman's home/end


  • More trailing-nil handling fixes.


  • Ctrl+B inserts a line break.
  • Added \reset & \run
  • Minor syntax fixies. (Around pico-8's questionably-parsed syntax)


  • Fix time()/t() not working correctly.


  • Supported copying/pasting in BBS. (Now that it's supported by pico)
  • Fixed syntax highlighting in long lines.
  • Fixed some... "security holes" in the repl. (__pairs, global overrides)


  • Syntax highlighting! (Customizable, too - see \cl)


  • Added \c to allow programmatically accessing code.
  • Added table printing ({1,2,3} instead of <table>), \mi
  • Some minor syntax fixies


  • Allow escape to bring up the pause menu when not used to cancel input.


  • Added paste support
  • 2 minor syntax bugfixes


  • Support goto and tailcalls
  • Fix recursion.


  • Fix expressions like 'type(nil)'


  • Support comments, bracket-string literals and all string literal escapes
  • Support dots/colons in function name


  • Added "\i=0" command to disable "interruptions" while executing code.
  • Fixed nasty glitch that would cause code to sometimes appear to be failing by spamming errors.
  • Fixed paging of 20*k+1 output lines


  • Original version, support for almost all pico-8/lua syntax.
P#71429 2019-12-26 23:09 ( Edited 2021-02-12 21:22)

Cart #fairchild001-10 | 2020-05-06 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Update 1 - full speed & better sound.
Update 2 - fix missing mouse cursor.
Update 3 - fix speed decrease in Pico8 0.2.0

What is this?

An emulator for the Fairchild Channel F, the first console to use programmable ROMs and a microprocessor.
The console was released in 1975, so don't expect much in the way of graphics, gameplay, or usability.
See Wikipedia for more info.

And what's that game running?

That's a homebrewed (i.e. - NOT original) game made by Blackbird and e5frog. You can find it here.
Any sound glitches are due to the emulator, not the game, by the way. (See below)

It pushes the capabilities of the console to its limits, so its quality is considerably higher than that of the other games for the console.
It's also anachronistic - the original Pac-Man wasn't released until 1980.

And how do I play other games?

In order to play other games, you first need the console's BIOS files and the ROM for the other game you want to play. (Having these is up to you and they cannot be shared)

If you have those, the easiest way to plug them into the emulator is to go to the below webpage which has the emulator together with a convenient UI to upload carts straight to pico-8. (Via the gpio pins, if you're wondering)

Load Other Carts Here

A less easy way is to bring this convenient UI over to the this webpage, by pressing Ctrl+Shift+I (or perhaps F12) to open developer tools and copy/pasting the contents of the following javascript file into the console (Note that it's not a good idea to copy/paste unknown javascript into the console in general):

Link to Javascript

By the way, a BIOS is needed since the "BIOS" included with the emulator is a homebrewed one which is only good enough for running a few games which don't use it much.

If you wish to copy the BIOS and ROM to the cart yourself - e.g. via cstore, they should be copied sequentially: BIOS SL31253 or SL90025 to location 0x0, BIOS SL31254 to location 0x400, and the cart to location 0x800. (Just like the Fairchild's own memory layout)

What are the controls?

In "1P" mode (default), the controls are:

  • arrow keys = move
  • Z = push
  • S/F = rotate left/right
  • E/D = push/pull
  • left shift = hold to control player 2 instead of player 1

In "2P" mode, the controls are:

  • arrow keys = move
  • N + arrow keys = rotate/push/pull
  • S/F/E/D = player 2 move
  • left shift + S/F/E/D = player 2 rotate/push/pull

In both modes, additional controls are:

  • X + left/down/up/right = press console key 1/2/3/4. (can also use the mouse)
  • X + Z = switch between 1P/2P modes. (can also use the mouse; only affects the controls)

What's working well?

All functionality is working and most likely bug-free, so all original and homebrew games work well, including the carts with extra memory.
(Exception: no support for the homebrewed multicart, which is too large for pico8 anyway)

Thanks to some optimizations, games now usually run at full speed.

What's not working well?

Sound has occasional glitches (either due to pico8's sound limitations or my implementation).

Keys sometime need to be pressed for a few moments to work in some games. This might be due to the original console's controls being slow to press.

What's the point of this?

Proving that emulators for non-trivial systems are possible to do in pico-8.
And just for the fun of creating and/or playing an emulator!

P#64568 2019-05-18 21:25 ( Edited 2020-05-06 02:26)

Cart #nilquesteasymode-0 | 2018-12-25 | Code ▽ | Embed ▽ | No License

Looking for the Code button? Click here!


Up/Down/Left/Right - move North/South/West/East
Z - Interact (Use / Pick up)
X - Use Item

The Story:

As part of the coming of age ceremony of your village, you are tasked with defeating the vile dragon atop the mountains north of town.

Your quest may be more complex than most as you were born blind, deaf, and without the sense of touch.

However, don't let that dissuade you! Where your senses fail you, perhaps your sense will prevail!
And so - your quest begins!

Easy Mode?

That's right! The original proved too hard to get started with, so this version contains some concessions to make that easier. The meat of the game is the same, so if you already beat the original, you won't find anything new here.

Just like the original, this version is completely safe-contained and requires only some programming knowledge to complete.

And unlike the original - for the first time ever - this version introduces startling 1x1x1bpp graphics!

Did I win?

If you have to ask, no. The victory screen is very explicit about it.

Looking for the Code button? Click here!

P#60357 2018-12-25 22:24 ( Edited 2018-12-25 22:44)

Cart #59190 | 2018-11-19 | Code ▽ | Embed ▽ | No License


Up/Down/Left/Right - move North/South/West/East
Z - Interact (Use / Pick up)
X - Use Item

The Story:

As part of the coming of age ceremony of your village, you are tasked with defeating the vile dragon atop the mountains north of town.

Your quest may be more complex than most as you were born blind, deaf, without the sense of touch, and without the ability to feel pain.

However, don't let that dissuade you! Where your senses fail you, perhaps your sense will prevail!
And so - your quest begins!


P#59191 2018-11-19 17:16 ( Edited 2018-11-29 19:47)

An implementation of standard-ish encryption using AES-256-CTR, PBKDF2 & SHA-256-HMAC


Q: What is the point of this? Is anybody expected to waste this metric ton of tokens on an encryption/decryption algorithm that's way too slow to run in pico-8?
A: That's not a question.

Q: Did you implement it from scratch? Are you aware that's that a really bad idea in cryptography, as your implementation is no doubt riddled with bugs and inefficiencies?
A: That's not a question.

Q: What's the password for the demo? Shouldn't the demo showcase successful decryption instead of a failure?!
A: That's not a question.

Q: #
A: 59190

A(cknowledgement): Demo uses print9 by qbicfeet for preddier text.

P#59188 2018-11-19 17:11 ( Edited 2018-11-20 02:07)

Follow Lexaloffle:        
Generated 2021-07-30 10:08:09 | 0.121s | Q:29