Here's a silly thing that came out of another thread where I was contemplating parsing game content out of strings, and just how far to take the idea. Eventually configuration/data formats always end up becoming programming languages (heck that's how Lua got its start), so why not just make it a full programming language from the start? Get a jump on Greenspun's 10th rule.
So, I implemented lisp-8, a small lisp dialect intended to be used in pico-8 carts. The core code is about 1400 tokens after some fairly aggressive (ugly) optimizations. I could cut it down by about 200 tokens if pico-8 ever exposed Lua's _G variable.
And of course, once you've got a scripting language embedded in your game, why not allow your players to type in code and make a full programming game out of it?
Of course, it might take a week to type in your program with the limited input available on pico-8. So if you don't want to type in code yourself, hit tab to cycle through some sample lisp statements.
This editor cartridge is, of course, itself implemented in lisp-8. It's all in the first _init function at the top of the code, the rest of the file is the lisp-8 engine.
Ultimately I don't know if this has any practical use at all, and it sure is slow, but it's kind of fun. It gave me lots of good ideas about how I can better compile together my assets for my actual pico-8 programming puzzle game, at least.
Wow, this is awesome - congrats! :D
I wanted something like this to save on tokens for my SCUMM-8 engine. In the end, I settled on having "packed" data definitions, as I wasn't smart enough to find a way to encode/serialize functions, expressions and loops!
If all my game code could be string-based, it might be possible to compress them somewhere into (potentially external) cart data.
Hmmm... you've given me lots to think about! ;o)
Hey thanks! SCUMM-8 looks great, I was drooling over it yesterday.
There's a lot of overkill in this current implementation, I was having a lot of fun with it, but it'd be interesting to trim it down and turn it into essentially a small interpreter with a hard-coded set of exposed functions. Basically an adventure game execution engine, like SCUMM was! :)
Hit me up if you want to chat more about the possibilities, I think it'd be fun. I'm @codekitchen on github and the social medias as well.
Thanks @tonechild. I'm not sure what you mean, are you talking about writing lisp code directly into the cart rather than in this little in-game editor toy? That's possible by using this cart as a template, the in-game editor is itself implemented using the lisp.
Hey it turns out that writing a game completely using an on-screen keyboard isn't so far-fetched after all! :D
Log in to post a comment