Data is awesome. Why not see how many blocks your quarry, tunnel bore, or even you yourself produce each minute, hour or day? With a simple LUA script, ComputerCraft, and ConstellationsDB you can do just that! No need to setup databases, servers, or even host anything. Just follow this guide and you too can make awesome looking dashboards!
A bit of context
ConstellationsDB is an all-in-one platform for data observability. What this means is that it collects all types of data, stores it for you, and creates graphs when you need them. This data can be anything from website visits to, in this example, a Minecraft quarries output. This post is only going to be touching on the basics of ConstellationsDB to get you up and running asap but the platform has so much to offer.
ComputerCraft is an amazing mod that lets you run scripts that interact with your Minecraft world, all using a programming language called Lua. For this tutorial, we'll be using a forked version of ComputerCraft called "CC: Tweaked". This "fork" adds a bunch of inventory addons into the mod, allowing us to see into chests, and move items. The same is possible in older editions of the game if you use OpenPeripherals but you will need to modifiy the code to make it work.
Heres the links to the resources you'll need. If your modpack already has ComputerCraft Tweaked, then dont worry about the top link.
Step 1: 🧰 Setup your chests and computer
First things first, you need to setup the chests and computer in a position you can manage easily. See the screenshot below for how we'll be doing it in the tutorial. You can change the direction to whatever you want, but you must make sure to change the code to match your input and output.
When setting up your chests, make sure you put a pipe or other transport method on the output that is as fast or faster than the input. This is because if the output chest is full, it will stop working until theres space.
Step 2: ✨ Setup Constellations
Once you have an account, you need to create whats known as a "namespace". This is basically a bucket of your data. Once you have a namespace, click on its name in the dashboard and copy the write key. You will need this to authenticate with the API and send data.
Constellations has tons of awesome features that you can try out for free. Free accounts can do almost anything however there are limitations on the amount a user can use. Constellations has a cap of 100,000 "events" (every stack thats moved from left to right chest counts as an event) per namespace so after a while your data will start overwriting the oldest data to stay within that 100,000 limit. However, even at a very high rate, you wouldnt need to worry about this cap unless you are constantly running the quarry for more than 7 days at max speed.
Step 3: 🍕 Code!
Dont worry, I wont make you type the script in line by line. You can run this one-liner that will download the LUA script required for this to work. Just copy and paste the following code block into your ComputerCraft computer's terminal to download the script:
pastebin get TDprQbeq count.lua
Step 3.5: ⚡ Fill in the missing details
Now you need to put in the details you got from Constellations into the script you just downloaded. This is super easy, all you need to do is type `edit count.lua` into the computer and you will be taken to an editor. Now you just need to copy paste the relevent details from Constellations into the top of the script. Once you are done, press shift and then enter to save, and then exit by doing the same but hitting exit.
Now you can run the script and it should start outputing what it's sending to the API when it shows up in the input chest.
Step 4: 💰 Profit / Visualise your statistics
Constellations is a super powerful tool that allows you collect data as well as visualise without needing to setup databases or APIs. While this step is not needed as data is now being stored with Constellations, this is a good idea as it will let you generate graphs and bar charts based on the blocks you've mined.
In your dashboard, you should go to "Dashboards" and click "New dashboard". Then fill in the details and click the newly created dashboard in the list. Your new dashboard is empty, but it will be full of wonderful graphs soon.
There are a few settings you need to do here but dont worry they are pretty simple. All you need to do is put in the namespace you created in step 2, then set the graph operation to "Sum". This will add all the blocks together instead of showing you the average stack size (this is most likely 64 and not very useful).
You can also configure the color of the graph, and various other settings here too! Just hit "Save" and your new graph will show up. You can drag the bottom-right corner to resize and move it around. Just remember to click the X in the top bar of the dashboard to quit edit mode. This will show you what it will look like normally.
Now what if you wanted to see the percentages of each block mined? Easy! All you need to do is create a "Tag Compare" graph. This will get the top few unique blocks mined and show you how many were mined in a time period.
Here's my personal dashboard that I built using all of the tools Constellations currently provides. Theres tons more cool features in the works so i'll be updating that as they release.
Constellations provides a super easy way to monitor anything. With the power of GET requests, you can build awesome dashboards without needing to run your own infrastructure.