Log In  

(This may sound convoluted)

Is it possible to invoke an embedded ("export html") pico-8 program's functions from an external javascript file?

In this particular case, I wrote a .js app that fetches remote data asynchronously (via ajax). I then want to map that data to a sequence of pico-8 program function names, invoking each one in turn at regular intervals.

P#32515 2016-11-15 13:51 ( Edited 2016-11-16 18:49)

:: alexr

I see you can emulate events by writing to pico8_buttons array. Not exactly what I had in mind but it's (infinitely) better than nothing.

Still, I need to map my data to (up to) 26 different actions (or, function invocations), so if anyone knows of a way, I'd love to hear from you.


P#32516 2016-11-15 14:14 ( Edited 2016-11-15 19:14)

If you assign a new Array(128) to the JavaScript global pico8_gpio, you can read from and write to Pico-8 memory 0x5f80-0x5fff. Use pokes and peeks on the Pico-8 side. The easiest method would be to map incoming values to functions in the _update loop. I can't think of a way to invoke an arbitrarily named function communicated over this memory range.

P#32529 2016-11-15 19:47 ( Edited 2016-11-16 00:47)
:: alexr

Perfect solution. Thanks for this. I'll figure it out for the function-to-peeked-value mapping.

P#32556 2016-11-16 13:49 ( Edited 2016-11-16 18:49)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-08-09 14:31 | 0.010s | 4194k | Q:18