FYI.

This story is over 5 years old.

Tech

Program a Virtual Computer in Minecraft To Control Stuff in the Real-World

Minecraft 'breaks the fourth wall.'

Computers exist in Minecraft, of course. You can build your own virtualized machine with a mod called OpenComputer (and probably others) and it will sure enough be a "real" computer. Different computers with different capabilities can be crafted from the mod's arsenal of modular components: graphics cards, network cards, redstone cards (redstone being the Minecraft version of electricity), sensors, holograms, robots, and more.

Advertisement

It's also possible to program Minecraft computers with the real-world programming language Lua. Unsurprisingly, one player (known as "giannoug" at hashbang.gr) decided to take this capability to its wonderfully absurd conclusion and create a program that can control some real lights in the real-world: "breaking the fourth wall," in giannoug's words.

Giannoug was able to accomplish this is less than an hour, in part thanks to some wi-fi-enabled light bulbs that just happened to be pre-hacked such that they could be controlled via TCP, a communications protocol that allows network nodes to exchange streams of data (vs. packets of data, as in IP). For the bulbs in question, that stream consisted of bytes corresponding to three RGB colors, the desired brightness of a fourth, white bulb, a mode switch (color or white), and that's it.

It looks like this:

0x56 RED GREEN BLUE WHITE MODE 0xAA

"OpenComputer works with redstone, so we can easily read the binary state of a Minecraft lever, either ON or OFF and toggle the WHITE byte to turn on or off the WiFi bulb," giannoug explains. "This is the computer I build in-game. It has 6 monitors that get combined to a big one, a disk drive and a redstone lever connected to the right side with redstone dust."

The final piece is a program to put it all together, which is where OpenComputer's Lua capability came in handy. I won't paste it all here, but the code is pretty short and doesn't look all that different from how you'd program the same system with an IRL computer.