Dec 2020
Made with node.js and Lua
Over winter break, my friends and I played a Minecraft modpack which included a certain mod called ComputerCraft. Among other things, this mod has functionalities to display images on in-game monitors, as well the ability to connect to the internet via websockets. To send images to these monitors, I made a webserver that handled HTTP and WS (websocket) requests.

For the webserver, I setup a localhost server on my computer that I exposed via ngrok.

You might notice that the URL has “ws” instead of “http”, which is because it’s for websocket connection. Replacing the “ws” with “http” leads to the website connection. Once the webserver was live, the websocket connection in-game would establish a connection and communicate the dimensions of the in-game monitor.
On the website side, there was a simple image upload form. The in-game monitors only had 16 colors and specific resolution, so the image needed to be downscaled and then compressed to 16 colors. I sent this data as a text-string via JSON (not the most efficient, but convenient).




The entire data package is sent alongside with the intended height and width of the image as a final check to ensure the destination monitor is the right size. The ComputerCraft computers used Lua, so I used a Lua JSON parsing library by rxi to handle the incoming data.

Once everything was parsed, the image could finally be displayed on the in-game monitors.

Here’s two more fun examples!



