Codeblocks is a plugin that allows you to control a robot by creating programs out of special blocks. The programs are ordered sequences of these blocks. The programming constructs available are: Functions, Looping through recursion, and Branching (If / Else) through Sensing/
Commands
run <program name> - Runs the specified program from the beginning
pause - Pauses execution of program
stop - Stops execution of program
resume - Continues execution of program where it was stopped
blocks - Clears inventory and fills it with code blocks
save - Saves programs
speed <number> - Sets the speed of program execution (1 is fastest, 20 is one instruction per second)
shift [number] - Shifts the column of code blocks the number of blocks away from the start of the program. If the number is ommitted, shifts by 1 block
unshift [number] - Shifts the column of code blocks towards the start of the program. If the number is ommitted, shifts by 1 block
compass - Indicates which cardinal direction you are facing
Robot Actions
Forward - The robot moves 1 block forward in the direction it is facing
Backward - The robot moves 1 block backward
Turn Right - The robot rotates 90 degrees clockwise
Turn Left - The robot rotates 90 degrees counter-clockwise
Up - The robot ascends 1 block
Down - The robot descends 1 block
Destroy - The robot removes a dirt or grass block directly in front of it
Defuse - The robot removes a TNT block directly in front of it
ShootArrow - The robot fires an arrow
Pickup Block - The robot will pickup the block in front of it. These blocks are placed in a stack internally
Place Block - The robot places the topmost block of its internal stack in front of itself
DigInFront - The robot will mine and collect the block in front of it
DigBelow - The robot will mine and collect the block below it
Blocks that require signs
Sense - The robot compares the block in front of it to the specified block. If the robot sees the specified block, it will continue executing actions placed on the green arrow. If it does not, it will instead execute actions placed on the red arrows. The first line of the sign on the Sense block needs to specifiy which block to sense for
Build - The robot will create the specified block at the specified location to the robot. The first line of the block needs to be the location relative to the robot. Possible locations are (Front, Back, Top, Bottom, Left, Right). The second line needs to be the type of block to place (e.g. Wood, Brick, Gold_Block, etc).
Function - The robot will perform the specified function. The function can be specified with either one or two lines. If only the first line is used, the system will assume that you are running a function that belongs to the program. If you use both lines, the system will look for the function that matches the name. See the section on functions for further explanation
Creating Programs
Programs are described by a sequence of blocks built from North to South (You can determine which direction you are facing by typing '/cb compass'). The start of a program needs to be a sign which describes the name of the program. The first line needs to be the word 'program' and the second line is the name (See below). The following program is named 'example1' and tells the robot to Move Forward, Turn Left, and Move Forward. To run the program, you would place a robot on the ground and type '/cb run example1'.
Functions
Creating a function is much like creating a program; however, instead of the first line of its starting sign having the word 'program', you instead place the name of the program the function belongs to.
To call a function, place a function block with a sign on top. The sign should read the name of the function. You can use shorthand by just writing the name - the system will look for a function with that name belonging to the program. You can also write the full name of the function (this allows you to call functions from other programs - on my server I have a set of 'global' functions that I use in several of my programs). Both of the function calls below reference the same function.
Looping
Looping is accomplished through recursion. To have a set of actions repeated, place the actions in a function and put a function call at the end of the function that tells the robot to perform the function again.
Sensing
Branching (If/Else) can be accomplished with the Sense Block. See above for an explanation.
Saving
The system remembers which programs belong to each player. This way, players can have programs and functions with identical names and not conflict. You can manually save your programs so that they will exist on server restart by typing '/cb save'. Additionally, all of the programs are saved when the plugin is disabled (i.e. on a graceful shutdown).
Dependencies
Requires the Spoutcraft client (Uses custom blocks)
Permissions
codeblocks.all - Gives access to the plugin
Texture Pack
The robot will be converted into a dispenser when it is placed on the ground. If you would like to have the robot retain its texture, you can use this texture pack. It is the default texture for Minecraft, with the one change that makes dispensers look like the robot.
This plugin was created as part of a research project. Upon running 5 programs, players will be prompted with a short survey. The survey must be completed to continue using the system. After 30 programs have been run, the survey will be shown again. Please try to take the survey seriously, we are very interested in your responses.
We are very open to suggestions and feature requests, so if there is something you would like to see added, let us know.