Wizard faces a chest

How to Send Over Data When You Can’t Send Over Data

Although the Twitch Dungeon Game needs no introduction, allow me to remind you of one of its core features: level creation. Viewers of the player’s livestream are able to create levels within Twitch using a Twitch extension (no external resources required!). Upon a viewer completing a level’s creation, the viewer will send over their level to the player’s game, and the player will be able to play the level.

It’s a neat concept, if I do say myself, however, implementing it proved to be a challenge. My group and I had trouble finding resources that were relevant to what we were trying to do, going as far as emailing the Cult of the Lamb developers (which responded!).

I was tasked with making the connection between the game and the extension. I got as far as authorizing the user, but I just couldn’t figure out how to connect them together. I realized that I was using up too much time, and then I came to an epiphany.

Before the project even started, I was messing around with Unity and the Twitch chat. I actually was able to send chat messages to Unity. With this experience, I thought “what if we could use this to send over the level data?”

However, the level data was stored in a JSON format. We didn’t want to just paste the JSON into the Twitch chat- it could be too big and was easily modifiable. So we came to our solution: compression!

Essentially, we’d take the JSON file, compress it into a string, and send it in the chat with a pretty “!room” command-bow on top. The game would receive the string and decompress it. From there, levels would be generated. A string would be sent instead of a larger JSON file, and while users could still potentially edit levels, viewers would have to go through some more effort to accomplish that goal. We had done it: the connection had been made.

Leave a Reply

Your email address will not be published. Required fields are marked *