cl

David Grace

Bay Area, California

Programmer, SysAdmin, Artist

Playing With Minecraft And Lua

We all know Minecraft. It’s a great tool for relaxing and creative building. I’ve spent many hours, alone or with friends, building and exploring.

There’s a lot of mods for Minecraft which have greatly extended its replay value. One of my favorites is ComputerCraft. It adds Lua-driven computers which can act upon redstone signals (Minecraft’s form of wiring) or drive signals on its own. Even better, you can control a robot called a Turtle.

Like it’s Logo namesake, the Turtle is driven with simple commands. Go Forward, Turn Left, Back up, etc. It’s a useful tool which can excavate large areas, or fill them up – But you must write code to make it go. There are plenty of pre-made programs which will dig out any size hole, but I just had to make my own!

I was fresh off a project which had used Lua extensively, and so I’ve come to like that language. It’s nice, simple, but fairly powerful. It reminds me a lot of early Python in that it doesn’t have outright built-in support for things like classes and object-oriented design, but it’s easy to implement everything with the tools you are given in the language itself. Plus, the compiler/runner is a nice little piece of standard C90 code which is very easy to integrate into a C/C++ project.

My Turtle control program is a bit different from most. It only does two things: Dig out rectangular sections, or fill them in. But it does so with lots of options, and a nifty color text-graphics user interface. The Turtle itself isn’t all that fancy but it contains a lot of useful utility code that will be handy if I ever take up another ComputerCraft project.

You can check out the Wiki describing how to use the code here: R.E.B. System Wiki.

The actual code can be found here: R.E.B. GitHub repo.