Just wanted to make sure I understood how things worked before diving into it too deeply.
So I understand the idea behind the pattern editor, I've used it to make short sound clips and stuff (and then these are obviously arranged within the music editor to make different instrument tracks, etc)
From what I can tell at a surface glance though, is that the music editor only supports one song. Is that correct? I get the impression that I can set the loop start/end points to choose between different pattern sets to allow for multiple songs (eg 0-7 might be song 1, 8-16 could be song 2, etc). Additionally, I assume that I can create my own pattern arrangements on the fly by means of poke()
Anyone know for sure?
Lua's standard library has a pair of handy functions called "tonumber()" and "tostring()", but they don't seem to be present with Pico8, which is unfortunate. I realized that you can get a lot more storage space by using strings, rather than sprite byte encoding, but passing it back into usable number data is challenging.
At best, I've got this so far:
function str2hex(str) local dd={} dd["0"] = 0 dd["1"] = 1 dd["2"] = 2 dd["3"] = 3 dd["4"] = 4 dd["5"] = 5 dd["6"] = 6 dd["7"] = 7 dd["8"] = 8 dd["9"] = 9 dd["a"] = 10 dd["b"] = 11 dd["c"] = 12 dd["d"] = 13 dd["e"] = 14 dd["f"] = 15 local obj={} for i=1,#str do obj[i]=dd[sub(str,i,i)] end return obj end |
Is it possible to take a string and index it or get individual characters from it? Ideally, I would like to convert to/from bytes to ascii characters. It looks like Lua 5.1 supports this in the standard library, but as far as I can tell, Pico-8 doesn't include it.
EDIT: I notice that I can use the # symbol preceding a token to get its length, such as a table or array or string, but I still can't directly index it.
EDIT2: After thoroughly reading the manual as much as possible, it looks like my answer is to use the sub() function.