Not sure exactly how to phrase this intelligently so...
How do I use the GPIO ports to send and receive data in the web player?
I managed to get a cart together that will send out a score to an endpoint so I can do stuff with it, which is awesome. I used this P8 snippet and it works great.
But I don't really understand what's happening or why...in both the JS and the Pico-8 code. I see a bunch of poke() commands and 256 math stuff but just don't know what they're doing. The P8 manual is pretty light on the GPIO stuff so I'm not sure where else to turn.
I saw someone on Twitter with a demo of a web player cart reading tweets, and that got me thinking about other things I could do with P8 carts if I had the ability to pull down data.
I'm not really looking to make a 2-player network game or anything...just wanting to pass data back and fourth.



For the PICO-8 code, you're poking into the gpio ports mentioned in the forums. For the JS code, it's similar to the pico8_buttons variable. You define a pico8_gpio variable near where you setup the module, then you pull from that every once in a while. However, there's no way to have the JS synced with the player, AFAIK.
Maybe there should be another variable the JavaScript can define, being pico8_update. Every frame, after updating, PICO-8 will check for that JavaScript variable. If it exists and is a function, it'll run the function.



I think a lot of my GPIO questions and answers like in the Twitter client over here: https://www.lexaloffle.com/bbs/?tid=3909
Gonna peruse that code and see what I can figure out, I think it holds the key.
[Please log in to post a comment]