Hi All! PICO-8 0.2.1b is now up on lexaloffle, Humble, itch.io, and for PocketCHIP. This update started as a continuation of 0.2.0 bug-fixing work, but I also relaxed my position on API minimalism just enough to add some new features :D
UPDATE: 0.2.1b is now live and fixes the print() bug, and a few other things. See the changelog below for details.
Ovals
You can draw ovals (technically, ellipses) both when running a cartridge, and when using the shape tools in the graphics/map editors. Ovals are specified by their boundary rectangle, and follow the usual draw state rules.
pattern={[0]= …,∧,░,⧗,▤,✽,★,✽, ˇ,░,▤,♪,░,✽,★,☉, ░,▤,♪,░,✽,★,☉,…, ∧,░,⧗,▤,✽,★,✽,★ } function _draw() cls(1) for i=0,31/32,1/32 do local x=64+cos(i+t()/8)*48 local y=64+sin(i+t()/8)*44 local w=8+cos(i*2+t()/2)*6 local h=8+sin(i*3+t()/2)*6 fillp(pattern[i*32]) ovalfill(x-w,y-h,x+w,y+h, (i*32)%8+8) end print("pico-8 0.2.1",40,62,13) end |
Serial I/O
To make it easier to set up workflows for getting data in and out of carts during development, some new serial() channels are available. You can turn a file on your host machine into a binary stream, or drag and drop it into the running cartridge to do the same. From the manual:
Additional channels are available for bytestreams to and from the host operating system. These are intended to be most useful for UNIX-like environments while developing toolchains, and are not available while running a BBS or exported cart. Maximum transfer rate in all cases is 64k/sec (blocks cpu). 0x800 dropped file // stat(120) returns TRUE when data available 0x802 dropped image // stat(121) returns TRUE when data available 0x804 stdin 0x805 stdout 0x806 file specifed with: pico8 -i filename 0x807 file specifed with: pico8 -o filename Image files dropped into PICO-8 show up on channel 0x802 as a bytestream: The first 4 bytes are the image's width and height (2 bytes each little-endian, like PEEK2), followed by the image in reading order, one byte per pixel, colour-fitted to the display palette at the time the file was dropped. |
Drag and Drop
On a related note, you can also now drop .p8.png cartridges into PICO-8 to open them. If there is a cartridge with unsaved changes, it will prompt before continuing. You can also drop .png files into the spritesheet, by first selecting the sprite that should be the top-left corner location.
API Changes
add() now comes with an optional 3rd parameter: an integer that specifies the location in the table that the new value should be inserted at. Similarly, a new variation of del() is available: deli(tbl, index) ("delete by index") allows deleting from a given location in the table rather than by value.
split() is also new. It complements the common strategy of storing data as strings. From the manual:
split str [separator] [convert_numbers] Split a string into a table of elements delimited by the given separator (defaults to ","). When convert_numbers is true, numerical tokens are stored as numbers (defaults to true). Empty elements are stored as empty strings. split("1,2,3") -- returns {1,2,3} split("one:two:3",":",false) -- returns {"one","two","3"} split("1,,2,") -- returns {1,"",2,""} |
Binary Storage
It is now also more efficient to store 8-bit binary data in the source code section, by encoding it as a binary string. The .p8.png format stores uncompressable sequences as a raw block of data, effectively allowing cart authors to choose how much of the code section to trade for raw binary storage.
Binary strings can be encoded by escaping characters that can't appear in the source code. For example:
0 should become "\000" (or "\0" when not followed by another number), etc. To make this easier, previously invisible characters C1..C15 have font entries, and also unicode replacements when copying and pasting. I'm working on a snippet for converting between data strings and raw binary data, to make this process easier. UPDATE: here's the snippet.
HTML Touch Support under iOS
Touch controls for HTML exports is now a little smoother, and works when running from inside an iFrame (including itch.io game pages). I removed the mobile buttons menu by default (the buttons along the top: fullscreen, sound, close) as they aren't very useful and are messy, but they can be turned back on in the options near the top of the exported html.
Changelog // added 0.2.1b
There are many other bug fixes in this update, but I haven't gotten around to replying to the BBS threads yet. For now, please check the complete changelog:
Nice! Love all of these and my urge to make a faux-textmode system for PICO-8 is rising.
It looks like 0x09, 0x0a and 0x0d are missing glyphs for me though? Running the amd64 version on Ubuntu 20.04.
@oakreef these are tab, carriage return, and line feed. They usually have no printable representation.
Ah yes of course. Zep's post made me think there was going to be non-whitespace characters for all the control characters but I didn't think about it very hard :P
testing it out print("test\10test") works just like print("test\ntest") now
now if only print("\7") also played a bell sound
I hadn't even finished flashing the unofficial API for 0.2.0h yet...
Thanks for fixing that 25-day video corruption bug. I was looking at some windows I had open earlier, after a long absence from programming mode, and I couldn't even read the source code to see if I should save it or not. That's a relief. :)
Also thanks for the indexed add/del stuff. I also hope that making them C-side helps perf a bit on embedded hardware.
Quick request:
Since a blank token string would otherwise be meaningless, would it be okay to request that split("abc","") result in {"a","b","c"}? Effectively say that the zero-width gap between characters is a delimiter. :)
Updated to v0.2.1b to fix some urgent bugs, and to add @Felice's suggestion (very handy!)
Added: split(str,"") splits by single characters
Updated: Tower of Archeos 1.1 via INSTALL_GAMES
Fixed: print(num,x,y) always prints numbers num in hexidecimal
Fixed: .p8.png decoder can enter an infinite loop (caused exports to freeze on boot)
Fixed: Can't save screenshot/gif when running a BBS cart with illegal characters in title.
Fixed: INSTALL_GAMES is broken
Fixed: Mouse is broken in HTML exports
@zep Awesome, can't wait to try this out! But I'm not entirely sure about split(str,""), if you're going to have a way to split by a single character, why not have a way to split by two, or three, or etc? As far as I can tell, split(str,num) wouldn't conflict with anything, but I could be wrong. Anyway, thanks for all your hard work!
@Spaz48 I second this, personally I think even split("hello",1) is more readable and as was said allows the convention of splitting things up by groups of more than one character.
When I try to import a PNG sheet, it is always loaded shifted one column to the right.
Is this a bug or am I doing something wrong?
OK turns out I had the second sprite selected and it would import with an X offset.
Weird thing is, the second sprite was selected by default :\
Thanks, @zep.
Is the index-out-of-bounds error the intended behavior when feeding add() with an index that's greater than the table size?
(as opposed to appending to the end instead)
You actually can add past the size of the table, but only by 1 entry, which matches the default behavior of appending. You basically have to be growing the sequence without any gaps (nil/uninitialized values), or else it's not a proper Lua sequence, whose definition is a little stricter than what we typically think of as an array.
I won't speak for zep but I would definitely assume that's the intended behavior.
@Felice
Sorry for not being clear. I meant to ask if it wasn't meant to revert to appending instead of inserting if an index out of range was given. Then again, I suppose I can't really think of a sensible scenario where that would happen anyway. Thanks for clarifying.
On a side note, is there an existing function in PICO-8 that counts all items in a table including non-indexed keys? Or do we still tally through a for-loop with pairs(tbl) for that? Maybe count() will eventually be re-implemented as that?
@zep Small UI bug I found. The angle snap for line drawing has a small glitch. Seem most visible in 45° X+/Y- and X-/Y+ directions. See gif:
@zep Found a small issue with PRINTH saving to desktop. It doesn't seem to work if you specify a file extension. So this works correctly:
printh("crazy","test",true,true) |
Whereas this won't work:
printh("crazy","test.txt",true,true) |
Instead, "test.txt" will be written to the cart directiory. Not sure if undocumented safety behavior or intentional?
Only tested it on Windows so far.
@zep to next version...how about adding a new 9th sound wave like the unique Atari 2600 noise/motor wave tone.
Could the png exporter automatically add the devkit mouse/keyboard logo on the cartridge if used ?
@zep Critical bug :
Disconnecting then reconnecting a controller twice will break the controller support.
On pocket devices it mean that PICO-8 will effectively lock the device if you put it it sleep mode twice in the same session.
I reproduced the behavior successfully on the windows, linux and raspberry pi version.
@choo-t
While I would certainly hope @zep would see your report in his own thread, ideally you should post bug reports in the support/bugs forum so they can be tracked and you can eventually mark your post as "fixed" (one hopes).
Zep, I can't update versions. Even though I got the game on Lexaloffle, the site is denying it. It says something like "No products found.", and I thought I'd ask you. Can you help?
[Please log in to post a comment]