How to start programming a workerbot Edit
- See also Training Mode
Pressing the space bar whistles; all workerbots will then pause (after finishing their current command) until you have selected a workerbot or pressed the escape key to cancel. After left-clicking a workerbot, you will see a "My Brain" window for that bot (see right). By pressing the red "Record" button, you will enter Training Mode, where you can train the workerbot by performing actions and configuring the instructions that appear.
All Commands Edit
- See also Training Mode#Controls for how to input some of these commands
Note that the commands refer to these terms:
- Time. How long it takes a bot to run a command (in seconds) not including command advancement time (which is always at least 1/60th of a second and can take longer depending on how well the game is performing); this command time may be skipped if the command fails. This time does not change based on the bot's current speed (which is reduced while a bot has very low charge). Below, times are rounded to the nearest millisecond.
- Charge Cost. Each workerbot has a limited charge (see the "Max Charge" column in Workerbots#Workerbot Details) which is reduced by this amount (numbers are technically inaccurate by up to 0.0005). A bot's movement also drains charge at a rate of 0.401 per tile (including diagonally).
- Command failure: some commands can fail (ex attempting to cut down a tree without an axe); workerbots will complain for some types of failures
- Command pausing failure: a type of failure that causes the bot to pause until the problem is fixed; while it is waiting, a timer icon will appear over it. If the bot is running a command inside one or more Repeat loops with their down-arrows set, the inner-most loop will break (all commands will be quickly skipped over and all loops will stop repeating until a loop with its down-arrow set is exited), after which all other loops will continue as normal.
For the images on this page, commands that refer to something generic (like "Find nearest target") will show an example (like "Find nearest Apple") instead.
Find nearest target Edit
Find the nearest target measured from the center of the search radius. The search radius defaults to the largest available range centered around where you trained the bot. Once a target is found, the bot reserves that item, preventing all bots (itself included) from finding that target in future searches. This reservation remains until the bot picks up the item, "find"s a different item, has its item picked up by the user, or its program is stopped by the player.
If a target cannot be found, a pausing failure results.
Because this command measures the distance between a potential target and the center of the search radius (instead of distance from itself), workerbots can skip over a target that is very close to it in favor of a target that is closer to the center of the search radius. The only way to mitigate this is to use beacons with smaller radiuses.
Move to targetEdit
Moves to the last target found by any Find command. Note that this command will not work as expected if a loop has been encountered since the last Find command. The name of the target on the command (ex, "Apple" in "Move to Apple") does not change anything.
Pick up target Edit
Picks up the last found target, if the target is close enough to the bot. This command only works if there has been a Find nearest target command with no loops in between. Note that the target on the command (ex, "Apple" in "Pick up Apple") does not change anything. The Move to target command is not required if the target is adjacent to the bot.)
This command will fail silently if the player picks up the object they are targeting or if the bot isn't adjacent to the target object.
Use held item Edit
Uses the held item, typically with regards to a recently found target. If the item cannot be used on the found target (or if it isn't even holding anything), the bot will complain. This command will fail silently if the target is not adjacent to the bot.
Stow held item Edit
If there is room in the inventory and something is being held, stows as many of the currently held item(s) into the inventory as will fit.
Cycle held item Edit
If there is an item in the inventory, cycles the currently held item. If programmed using the , or . keys, it will cycle in the same direction you used, otherwise it will cycle in the same direction as the , key.
Move to building Edit
Move to the target building, if accessible. Note that this command refers to the specific building it was created with, not the nearest building of its type; this building can be changed by clicking the circle at the end of the command.
Add to building Edit
Add the currently held item to the target building. This command will fail silently if the bot isn't adjacent to the target building or if the bot doesn't have any items to add to the building. This command will have a pausing failure if the storage is full.
Take from building Edit
Take an item from the target building (which can only be some sort of storage). This command will fail silently if the bot isn't adjacent to the target building. This command will create a breaking failure if the storage is full.
Move to location Edit
Move to the target coordinate, if accessible.
This command is created when whenever you right-click on a tile and is automatically exchanged for a more relevant command if your character attempts to perform an action on arriving at that tile (such as picking something up).
Find nearest blueprint Edit
Find the nearest blueprint measured from the center of the search radius (which defaults to the largest available range centered around where you trained the bot).
Only blueprints that need the item that the bot is currently holding will be considered. If the bot is not holding anything and also has nothing in its inventory, then this command has an immediate silent failure (the command is skipped immediately). If it isn't holding anything and there is something in the its inventory, it has a pausing failure.
Note that bots do not "reserve" slots in blueprints, so if two bots are trying to add the same ingredient, they can both target a blueprint that only needs one more of that ingredient.
Move to blueprint Edit
Add to blueprint Edit
Add the currently held item to the target blueprint. This command will fail silently if the bot isn't adjacent to the target building or if the bot doesn't have any items to add to the building. This command will have a pausing failure if the blueprint doesn't need what the bot is currently holding.
Causes the workerbot to wait for the specified amount of time (in addition to the command advancement time).
Shouts a message to other workerbots (works at any range); these shouts are invisible to the player. They can listen for these shouts using Repeat until hear.
Repeat loops will repeat a bunch of code while a condition is true; it will not run the loop even once if the condition is false. The condition is only checked at the beginning of each loop iteration (that is, it is not checked while the bot is running commands inside the loop). Note that loops can be nested (inserted into each other) to create more complex behavior.
All the headings in this section (except the first) describe the different condition options. The conditions are described with the assumption that the down-arrow is not set (see first section).
Repeat arrow Edit
Repeat loops have a checkbox at the far right of their first line; if set, they display a down-arrow. If such a loop is being run and a pausing failure occurs, command execution breaks out of the loop (instead of the bot waiting for the problem to go away, as normal). In such a case, the execution of all commands is skipped and all loops stop repeating until a loop with a down-arrow is exited.
Repeats the loop forever.
Repeats the loop a specified number of times.
Until hands full Edit
Repeats the loop while the bot could carry more items. (Thus, if a bot is holding a single tool, this loop will not run since you cannot hold two tools at once.)
Until hands empty Edit
Repeats the loop while the bot is carrying at least one item.
Until inventory full Edit
Repeats the loop while the bot could hold more items in its inventory.
Until inventory empty Edit
Repeats the loop while the bot has anything in its inventory.
Until storage full Edit
Repeats the loop while the storage is no more than 94% full.
Until storage not full Edit
Repeats the loop while the storage at most 94% full.
Until container full Edit
Repeats the loop while the container the bot is currently holding is not full. (An example of a container is a basket.)
Until container empty Edit
Repeats the loop while the container the bot is currently holding contains something.
Until hear Edit
Repeats the loop until the the bot has heard the specified message; then the bot "forgets" that it heard that particular message (so that it can enter the loop the next time this condition is evaluated). The text is case-sensitive, so "Hello" is different than "hello". The bot can hear the message at any time, including before the loop starts running.
- You cannot copy/paste commands within the same bot (though you can copy/paste programs between bots using Crude Data Storage)
- There are no if statements (though you can get some conditional behavior with clever use of loops)
- There are no variables, functions, or re-usable modules