Craftomation 101 – Eating and Maintaining Bonfires Guide for New Players

Beginners Guide to Eating and Maintaining Bonfires

Сrеdit gоеs to JOHNNY GUEGGU!

This guide will explain four concepts in a simple, easy to understand way:

  • Variables.
  • Functions.
  • Eating.
  • Maintaining bonfires (in a very simple, but super adaptable way).

Introduction

Welcome to this easy to understand guide about the very basics of the game: Eating and maintaining fire.

There have been quite a few questions in the forum about maintaining fires, so let’s see how we can do it in a super simple, but very adaptable way.

Variables

Variables in this game are blocks that can hold values.

These variable-blocks can be filled dynamically (by other blocks) or statically (filled by you).

We are only going to use the easy, static way of filling them in this guide.

Functions

Functions are blocks, just like any other block, which you can use in the game.

Imagine you have established a process of doing something in 3 steps.

A simple example would be:

  • Check energy level.
  • Find food.
  • Eat food.

You will use these 3 steps allover your code.

Wouldn’t it be neat to pack these 3 steps into a single block that you can use repeatedly?

That’s what functions are for!

Functions and Variables

Functions, together with variables make our code super clean and neat:

Explanation:

  • Orange-marked blocks are variables.
  • Yellow-marked blocks are functions.

This is the beauty of functions: They hide away all the underlying complexity into a single, easy to use block!

The “Eating” Function

Here’s a simple bot that eats, crafts a flame and stores that flame into storage:

Looks really simple, right?

That’s because we hid away the complexity into functions.

So let’s look at a simple, reuseable eating-function:

This function:

  • Checks if the energy is low.
  • If it is, the bot will store all items it holds in it’s hands into a storage-location, which you can pass to the function via a variable:
  • It will then find the food-depot (which you can also enter via a variable, but since I only have one, I hardcoded it into the function). It’ll check the food-storage if it is empty. If it is not, it will pick food and eat it.
  • Lastly, the bot will compare it’s energy-level with a pre-defined value. Coal-bricks give 25 energy. So if the bot is at 75 energy or below, it will continue eating:

The neat thing is that you can use this function everywhere, because it’s autonomous.

No matter what the bot is holding, or what energy-level the bot is currently at, the bot will go and eat, and it’ll keep eating up to it’s maximum possible energy level, without over-eating (wasting resources).

Maintaining Bonfires Using Functions

The goal here is that one bot maintains many bonfires.

But how do we do that? Do we have to come up with a separate function for each bonfire, repeating the same blocks several times?

No. We just write one single function of how to maintain a bonfire, and then keep re-using it all over:

  • As you can see in the image above, the “MaintainFire”-function is always the same, and we can easily re-use several times inside the same (or even a different) bot.
  • We also add four simple variables (green blocks) to make the entire function dynamic!
  • The upper green block (variable) is our flames-storage. It’s the location where the bot should pick it’s flames from.
  • The lower three green blocks (also variables) each hold one single bonfire-location.

Simple, right?

This way, if you want another bot to maintain another set of bonfires you just:

  • Copy over the code.
  • Maybe adapt the storage-variable where the bot should pick up the flames.
  • Definitely adapt the other 3 variables that are holding the cordinates of the bonfires that the bot should maintain.

Since we made functions for everything, combined with the fact that functions are modular and variables can be adapted, we can daisy-chain our functions together! This way, one single bot can easily maintain one, two or three bonfires, while also never running out of energy:

The Maintain Fire Function

Looks a bit complicated, right? But it’s really easy.

  • If the bot’s hands are empty, it will check a storage-location (which we enter via a variable) and see if there are flames inside.
  • If there are, he’ll pick one flame.
  • If the bot’s hands are not full yet, he’ll pick another flame.
  • When the bot has 2 flames in its hands, the bot will go and check the bonfire’s location.
  • The bonfire-location itself gets passed to the function via an easily adaptable variable.
  • If the bonfire at the given location still holds a number of flames above the threshold (10 here), the function will stop.
  • If the bonfire’s number of flames is below the threshold, the bot will drop both flames he is currently holding into the bonfire.

This last point might seem strange. What if there are 9 flames left in the bonfire? Then the bot will overfeed the bonfire. He will throw both flames he’s holding into the bonfire, and there will now be eleven flames inside it.

In fact, this “overfeeding” makes sense: You want to go over the threshold, otherwise the bot will come back all the time, because the threshold gets triggered anew.

So in fact, nine is our lucky number here. Because if we hit this number of flames in a bonfire, it means that we’ll overfeed the bonfire and we won’t have to return to this particular bonfire for a longer period of time.

Egor Opleuha
About Egor Opleuha 7618 Articles
Egor Opleuha, also known as Juzzzie, is the Editor-in-Chief of Gameplay Tips. He is a writer with more than 12 years of experience in writing and editing online content. His favorite game was and still is the third part of the legendary Heroes of Might and Magic saga. He prefers to spend all his free time playing retro games and new indie games.

Be the first to comment

Leave a Reply

Your email address will not be published.


*