In the workshop, Subarno demonstrated the Drone object. This a great helper library that comes with ScriptCraft and makes a lot of building tasks easy. It’s explained in a fair amount of detail in The Young Person’s Guide to Programming in Minecraft and in more extensive detail in the ScriptCraft API Reference.
For example, if you want to make a block of stone that is five bricks wide, five bricks high, and five bricks deep, you’d use the following command to invoke the drone.
box(1,5,5,5);
The first argument is the ID of the type of block. It can be a number like 1 for granite and 46 for TNT, or you can use one of the constants like blocks.oak
. The following three numbers are the width, height, and depth. To make the same size shape, but hollow inside and open at the top and bottom, you’d use:
box0(1,5,5,5);
Subarno showed off a plugin he’d built called “My Fortress”. Here is the code for it…
function myfortress(){
//set a checkpoint where we're starting
//then build a square shape 10 blocks long per side and 5 blocks high
this
.chkpt('myfortress')
.box0(1,10,5,10)
.up(2)
for(var i = 1; i <=6; i++){
this.right(2)
.box(102,1,1,1)
.back
if( i === 3 ) this.right(3).turn(3)
}
//return the drone to the starting point.
this.move('myfortress');
};
var Drone = require('drone');
Drone.extend( myfortress );
Then there's Subarno's pretty fun Exploding Fortress...
function myExplodingFortress(){
this.chkpt('myfortress');
for ( var l = 0; l <= 4; l++){
this.box0(46,60,10,60)
.fwd()
.box0(51,1,1,1)
.up(2)
}
this.move('myfortress');
}
var Drone = require('drone');
Drone.extend( myExplodingFortress );
And last, Subarno's mybase()
function mybase(){ this.chkpt('mybase') .box0(97,21,20,30) .right(11) .box(51,2,5,1) .back() .box(108,4,1,1) .fwd(10) .left(14) .move('mybase') .box(97,21,1,30) .move('mybase') .up(20) .prism0(97,21,30,30) .move('mybase'); } var Drone = require('drone'); Drone.extend( mybase );