Log In  

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.

Cart #39744 | 2017-04-18 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
18

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.

P#39746 2017-04-18 00:04 ( Edited 2018-10-31 16:37)

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)

P#39750 2017-04-18 01:13 ( Edited 2017-04-18 05:41)

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.

P#39761 2017-04-18 15:48 ( Edited 2017-04-18 19:48)

Thanks back at'cha! ;o)

Totally agree, makes perfect sense (and would be so fitting!).

Thanks also for the offer, will be in touch soon. In the meantime, all the best with your lisp-8/logic gates game!

P#39762 2017-04-18 16:21 ( Edited 2017-04-18 20:21)

dude very cool thanks so much for making this!!!

Would be nice to use the interpreter against the in game editor though

P#39815 2017-04-22 10:07 ( Edited 2017-04-22 14:08)

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.

P#39900 2017-04-24 10:42 ( Edited 2017-04-24 14:42)

Hey it turns out that writing a game completely using an on-screen keyboard isn't so far-fetched after all! :D

https://arstechnica.com/gaming/2017/04/the-first-kirby-game-was-programmed-without-a-keyboard/

P#39980 2017-04-27 11:59 ( Edited 2017-04-27 15:59)

This is really cool! Any plans to update it to allow keyboard inputs?

P#58570 2018-10-31 12:12 ( Edited 2018-10-31 16:12)

The concept of making a mini-language from an existing one is definitely not new. Look at PICO ! :)

I hope in time I can release this miniature BASIC I wanted to write in PICO where you load/save programs in sets of 256-bytes.

It will be a little bit more simplistic than LUA in retrieving and setting variable values, however.

a$="hello"
print a$
print a
print a[1]
print a$[1]
a$[0]="q"
print a$
a$[-1]="x"
print a$

Will reveal:

hello
104
101
e
qello
qellx

Essentially, strings are numeric arrays containing one of two types of numbers in a table. 0-255 for a single character or -32768 to 32767 or 0 to 65535 for 2-characters, of -32767.9999 to 32767.9999 for 4-characters, and they can be linked.

P#58571 2018-10-31 12:37 ( Edited 2018-10-31 16:43)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 04:21:46 | 0.025s | Q:29