Welcome to the Bitcave! Nerdiness, Jokes, Mods, Ideas, and coding!

Welcome to the BitCave!

Last Updated 12:27am PDT 02/11/14

This is Bits, and I’d like to welcome you to the BitCave, a central thread for discussion of the technical, design and coding aspects of Lua, AI, and Mods in general (I wish there was a way to Cross-Post). There will be tons of resources in this thread, and I will update the OP regularly with new info and ideas (It’s likely to get quite long). So with that, a disclaimer:


This thread contains learning, humor, and more nerdiness. If you do not want to become infected, please direct your mouse to your back button and click vigorously until safety is assured, sometime after ~3000 clicks. Symptoms of learning include, but are not limited to:

  • Mild loss of giving a crap about anything but this cool new thing you’ve learned.
  • Knowing stuff, and being ‘That Guy who knows stuff’ in conversations.
  • Experiencing idea cascades leading to sleeplessness, excitability, obsessive tendencies and a lack of measurable productivity
  • A secondary symptom is eye and finger strain from clicking through and reading too much Wikipedia
  • A penchant for correct spelling and a mocking disregard for correct grammar do.
  • Magical beans which you decide are fake until scientifically proven to be magical.
  • A shockingly adverse allergy to stupid.

If you experience ANY combination of these symptoms, it is highly likely that you have begun LEARNING, a dangerous, unregulated mental compulsion that can quickly lead to the demise of ignorance and an explosion of unfettered curiosity, And big words. If this happens to you, please consult a physician about how he got his job and how you can teach it to yourself using WebMD. THEY LOVE THIS.

So, on to the useful bits!


First we will go over places to learn Lua, the coding language used to write Mods and Additions to the game. Lua is a pretty uniform language, so you’ll want to specifically learn how further functions and processes are implemented in it. Radiant will most likely be providing us a ton of function that will serve as an API (Application Programming Interface) to connect us into the magic that is Stonehearth’s core, so knowing how to implement and use the various Lua bindings a program will have, not so much specifically, but generally, will be the first thing you need to master. I also write in way too many run-on sentences, so here’s a list:

Lua Tutorials

Places to Practice




References From This Very Forum (THANKS @SteveAdamo!)

More From the Forum! (Thanks @voxel_pirate)

Once you know the basics, You’ll need a place to implement it, and test your skills within an actual program. There are quite a few that already support it, but here are three of my favorites:

Once you get primed and ready, and become a Master Lua Slinger, spitting code so hot that it burns straight to the concrete floor of your mother’s basement, You will want to know where you can actually use this stuff. Well as a bonus that’s what the next section is about.

AI discussions and dissections within this topic

Logic and AI, and Making Yours Better Than Theirs

It’s no secret that my first mod project is gigantic, that it’s essentially building a competitive AI Smackdown ladder where the hackers who can best optimize, improve and streamline their voxel-based pals can rise to the top and create Skynet. Or something. So, in that vein I have found some slightly more advanced articles on A* (pronounced ‘a-star’) pathfinding and AI logic. Save the Stanford article until you’re in that mood. You know, the one where you want your brain to pop. In order of complexity:

Further Reading

And finally, we have a spattering of articles on Gamasutra about AI, Storytelling, and Design:

Some of these are fascinating, some slogs through technical details and some might be more for @Ponder and @Tom than for any of us. Though they’ve prolly already read them. :smile:

Anyhow, now that we have a grasp of Lua, some fiddling experience with it, some knowledge of AI and Logic, and ideas spawned from reading random articles, let’s get to the good stuff.

Mod Ideas and Development Fun

This is where I dump all of my mod ideas, flesh them out, and once we have some beta, dump code and stuff. First, as you’d expect, is:


What is an AI Smackdown? Who cares? It’s awesome and I care, that’s what! Some of you may remember me mentioning it during the Pizza Party, but here’s the gist:

Given how ridiculously moddable Stonehearth is shaping up to be, the fact that the units are somewhat autonomous, and the ease of programming in Lua (It's really not super hard!), I believe it is the perfect place to allow people to customize their AI, in addition to their Kingdom, and pit that AI against another Player's (or another of their own) in brutal, efficient combat. 

The general plan is to provide an alternative ladder for AI modders (as I doubt mods will be allowed in competitive vanilla play. Read: I GAVE MYSELF DRAGON ARMOR AND INVISIBILITY!) to pit there modded logic and pathfinding against that of their friends and rivals. Will your troops turtle up behind bottlenecks and wait for the enemy to flood into the killing field? Or will your troops perform strategic raids, striking like a blitzkrieg before making a quick tactical retreat before hailing arrows into your pursuers?

As would most definitely be necessary, there will be balancing of the ladder over time. Glitching will most likely be prohibited (glitching being a way of guaranteeing a win through taking advantage of bugs.) But initially it will be a rumpus house of creative juices flowing into Lua magic. We would go from, "Oh look a nearby enemy, punch it until it dies" to "OH CRAP BAD GUYS! TELL EVERYONE TO GO TO DEFCON 'OHSHIT' AND BARRICADE THE WALLS! UNIT A TO POSTS! UNIT B FOCUS FIRE ON MY TARGET!" or something like that. I really can't wait.

Ideally the system would be self-regulating, but I know that there will be some ne'er-do-wells. So the real key to implementing this won't be figuring out how to enable mods in my sideloaded competitive ladder, it will be introducing self-regulation to limit or deny players with invincibility mods and so forth. I'm thinking providing tools for the community to self-regulate will be best. Beyond that, once beta comes out I will be diving into AI programming, starting with trying to sort out getting your units to communicate efficiently, then teaching them how to get places more better do, and finally making them read The Art of War.

This is extremely early design, so I'll be updating and uploading graphics, designs, simple challenges to hone your skills, and eventually (if I really get a lot of spare time) I will be compiling it into a manual to get started. I have to come up with a name for the ladder, probably have to get a domain to manage it, and I'm going to be reaching out to schools and universities once it's released to allow the largest number of people to participate.

@Tom & @Ponder, I do kind of wonder if down the road you’d be willing to officially (not really fiscally) back major educational AI Romps. Would you? < /Didyareadittest >

Audio Injection API/GUI

Once the game comes out, I’ll be slapping up an API/GUI to inject music of your choosing into the game. So if you want @Raj’s or @CaseyEdwards’ music in your game, in addition (or replacing) the stock music, you can totally do that. I am entirely confident that the default musical score will be epic, but I’m all about choice, and this reflects that. If I do end up creating an API, it will allow for detailed event scripting, and will function mostly as a library for mods that would like to add scripted musical events easily and quickly (essentially it would be a function that would allow you to play, pause, stop, loop, and control the relative volume of an asset or a (randomized?) playlist of assets, in whatever auditory formats Stonehearth natively supports (adding new ones may present licensing challenges… Time will tell.)

Other Stuff!


Daily Learning Challenge! (Still sort of on Hiatus.)

I’m almost done for the day, but today’s challenge is using computercraft or one of these (one) (two) emulators to create a program that could be construed as a hilariously broken Spelling Bee. (Broken as the answers are in the question.) and post your Lua code to the thread (Use a pastebin if it’s huge and make sure to select Lua as the codetype!). Show us that you can handle update loops, user input, and string comparison! Most efficient code gets a shoutout (! @Xavion !) , and will be immortalized in this post! (The emulators are multiplatform @Xavion :smile: )

Challenge Two was downloading Decoda, the software Radiant uses to debug their code, and playing around with it. Make it through the first luatut page! Best of luck!

Challenge One was getting luaforwindows installed on your machine! Go You! You can do it!


excellent compilation @bitassassin:+1: for reference here’s a handful of local threads:


For information about everything Procedural Generation


@SteveAdamo and @Ondaderthad I’ve now added both of your additions! Thanks so much!

Updated the page! I added the AI Smackdown Section, in case anyone wanted more details on the mod I’m gonna be working on!

1 Like

In the future please avoid os specific challenge’s.

Also the AI stuff seem interesting but it’ll be interesting to see how good it is in the first place as it should be alright by default. For mods and the ladder maybe go approved list of mods, separate ladders for major mods+vanilla, plus a general ladder for all mods that requires adapting to what there is installed.

The luatut site is actually cross-platform and has an interpreter built into it for you to perform the tutorials. I prolly should have mentioned that. Linux users should be savvy enough to install an IDE, and I don’t even know where to start on Mac.

As for the AI mod and ladder, the initial point is the AI war. Good enough is never perfect when it comes to AI. Slight differences in AI can make for utterly awesome or disastrous changes to a clan’s hopes for survival in the ladder.

Look at Battlecode.

Any implementation for other classes of mods initially would be complete, unregulated chaos. I already know I’m going to be working on preventing wall-hacks, over-zealous sight ranges, and speed hacks. It’s just expected. That would get even worse with more inclusion. Eventually, yeah. At the start, no.

Thank you for keeping the criticism constructive. It’s much appreciated.

Either way I’m super excited.

I’m out,


1 Like

as a hobbyist myself, pathfinding and other forms of AI logic have always fascinated me… this is the single best resource i have ever used on the topic…

Uhh… Bookmarked!? :smiley: Thanks.

Well, this is yet ANOTHER kick in the pants to get me to learn LUA… And I thought school ending meant I’d have much LESS learning to do…

@SteveAdamo Omg, so awesome. Added. You should read that Stanford paper at some point. It’s… interesting. It’s got some history of AI that I find pretty fun.

@Paranundrox Do you play minecraft?

Yes, I do (or did, rather). I don’t ever play vanilla anymore, just Feed the Beast occasionally with friends.

ComputerCraft is included in Feed the Beast! =D Start at their wiki, and set up some door locks, then a redstone clock, and so forth. Hell I turned one into an infinijukebox. (Because I get tired of the lack of music in MC).

Computercraft is how I started In Lua, and it’s damn fun once you get to the advanced computer (Vid)! I should note that that is not me.

1 Like

I used to use computercraft a while back, haven’t used since they added the advanced computers though so it’s been a while. Anyway the point of this was to point out something, that site that @SteveAdamo gave is good and I’ve never seen that part before but here is a link to the other half that has everything games, from design to custom scripting languages to guides on medieval economics it’s a generally very useful list.


sorry! i should have listed that as well… burned far too many cycles reading up on some pretty obscure topics… :wink:

Excellent resources, thanks.
so much to learn, so little time…

Does Lua work like Minecraft consoles?

hi @samkrox98 … im not sure i follow the question… if you are referring to the computercraft mod, then yes, to a certain extent they are similar… both rely on the Lua scripting language, so if you are already comfortable with computercraft (and have grasped the basics of the language), you will be off to a good head start for using Lua in Stonehearth… :smiley:

I fiddled around in Computercraft a little bit and, I have to admit I understand lua a lot better having put it to (some) use and having a goal in mind, rather than just looking at hypothetical scenarios, I guess it just helps to have something to work towards…

1 Like

@bitassassin, I think the key to keeping it fair in the mod wars you are discussing, is to simply regulate the kinds of mods that are being implemented. There has got to be a way to say “only mods that modify AI’s allowed”. I mean there is probably a huge difference between a mod that gives you dragon armor, and a mod that changes the way things are already in the game behave, since it doesn’t change any base attributes, right?

I don’t know if all that made any sense, but basically what I’m saying is, wouldn’t it be possible to set the server (or whatever) to not accept mods that change in game attributes, such as attack and defense, and instead only accept mods that change the decision making of AI’s. Priorities and what not, like Tom/Tony (I’ll be honest, I can never tell who is talking to us) mentioned a while earlier in a live stream.