(5 minute read.)
Computercraft is glue. It’s that sticky Elmer’s glue that seems to attach to everything except where you want it to. In programming, there is the notion of ‘glue code’. I’m sure you’ve heard of it. It is the code that sits between two systems and makes them play nicely. It’s rarely big and impressive, but it is clearly important. Glue code is the tiny hidden wrappers that allow you to call OS code from a high-level language like C#. It is everywhere below the surface. It acts very much like the glue in your junk drawer. Occasionally, you pull it out and use it to attach two completely different things together, and then you never have to think of them as separate ever again. They are now one. This is what Computercraft (CC) is. Let me explain.
In Minecraft, the world is as open as your imagination. So are the game files, as it happens… years of decompilation efforts from the community, with a sprinkle of endorsement from Mojang, we have made something huge. There is an entire ecosystem of Minecraft mods and frameworks that change the game in imaginative ways. You have the ones that add nuclear bombs, one that adds wives, electronics, and at least one that turns it explicit. The creativity is endless, and the variety is enormous. Of all the infinite problems and solutions modders have added to the game, rarely do they solve problems the same way and account for other mods’ cheeky hacks. How could they anticipate all the forms of this creativity? Even today, with the modding scene matured, rushed mods crash the game. At the best of items, their mechanics are completely isolated. They are wildly different systems made by individuals all over the world. The only thing they have in common is the game engine (Hytale doesn’t even have that anymore!). With different kinds of systems side-by-side, glue becomes vital.
Some mods have attempted to address this, designed entirely around adding compatibility. Another ore bites the dust. Forge’s unified API’s for energy, fluid, logging, etc. There has been genuine progress in solving what were real systemic problems, like incompatible electricity. While these solutions are good, they’re always playing catch-up. No unified system can handle the unique idiosyncrasies of two mods interacting in edge cases nobody expected. This – I insist to you – is what Computercraft does best. This is the glue hypothesis of Computercraft.
CC is a platform more than anything else. It provides a programming language sandbox with simplified APIs to manipulate the world in simple ways. You can dig blocks, read from chests, work with redstone, and many other things. All useful features in their own right. With other mods at play, these superficial features start to have emergent properties. With redstone, you can activate or pause machines. With block-breaking, you can automate entire purpose-built farms and niche mining practices. With the (creative only) command computers, you can quite literally change the rules of the game on the fly without limitation. Before you know it, you’ve turned your whole world into a factory that makes everything from scratch in a grand pneumatic dance.
I have made so many Computercraft scripts that I’ve lost count. The most impressive I can name is an API for testing redstone circuits to the exact game tick. It’s accurate, and this tool is valuable when building cutting-edge redstone. I made it specifically for making my own CPU in Minecraft; working on that project without testing would make bug squashing nightmarish. I could have made my own Minecraft mod, but I chose not to because CC has good integration with other mods, ease of use, and power.
The language of choice for Computercraft is Lua. You may well roll your eyes at this one – Lua is almost an antique by now. You could polish it and display it on the mantelpiece next to Grandma’s plates, and it would not look out of place. What is good about Lua is that it’s simple. The simplicity is a huge part of what makes CC a good glue. Lua is not super fast or strict, but it is well-defined and straightforward. It also happens to be sandboxed, which is good for stability. The unstable internals of the Minecraft codebase rarely leak out into Computercraft. What’s more, these scripts work on any version of Minecraft since its first release in 2011. Fifteen years ago.
Ok, time for some housekeeping. Let’s take out the rubbish. When I say scripts work on any version of Minecraft, that is partly rubbish. Let’s bag that one up. In practice, you will need to port scripts across versions of CC and any mods it interacts with. Whilst the skeleton of the code is compatible, many of the APIs are buggy. This is especially true of third-party APIs from other mods. If a mod does provide bindings, expect them to be buggy, inconsistent, and undocumented. All workable, but keep it in mind. In the bin you go, trash. Despite the practical incompatibilities, I still think there is enormous value in at least the stable structure of CC’s APIs.
Despite all the quirks, I keep coming back. So many modpacks quietly include Computercraft in the game. Like spills that are wiped up, Computercraft is everywhere, but nobody sees it. This mod has taught me many foundational programming principles. I keep coming back for a quick scrub because, above all, it’s fun and I can solve problems with it with comparatively little time investment. There is always more to learn, and every modpack has its own fun variation of peripheral APIs. Every modpack has its own overlapping oddities, and there is no better way to account for them than a Computercraft glue script. You should make your own someday.
Ed balls