Minecraft Programming – Creating Buildings with ScriptCraft Functions on CanaryMod

Standard

Ok after successfully stacking blocks or making buildings using ScriptCraft one-line command, now our kids programming class start to create something like this using functions:

Tangkapan layar 2015-03-10 18.05.11

There are some tricks to make ScriptCraft functions work. First, you have to save it in the right folder: plugins/drone/contrib/ . Second, you have to make sure that there is no errors. CanaryMod server is very helpful at pointing where the problems occur:

Tangkapan layar 2015-03-10 18.46.46

CanaryMod also make it possible to set up everything about the game. To practice with buildings, this is the setting should be set:
Bildschirmfoto 2015-03-11 um 8.29.08 vorm.
This will give you a flat empty world. If you want to start a new empty world, or apply new settings, just delete the world folder. Next time you start up CanaryMod server, it will generate a new world for you like this:

Tangkapan layar 2015-03-10 18.46.32

This is an example of ScriptCraft function to create a skycraper:

 
var Drone = require('../drone').Drone;
var blocks = require('blocks');

function skyscraper( floors )
{
echo(floors);
this.chkpt('skyscraper');
for (var i = 0; i < floors; i++)
{
this.box(blocks.iron,20,1,20).up().box0(blocks.glass_pane,20,3,30).up(3);
}
this.move('skyscraper');
};

Drone.extend(skyscraper);

just type it on the command line:

Tangkapan layar 2015-03-10 20.14.31

and you’ll get this:

Tangkapan layar 2015-03-10 20.15.08

this is another simpler function, just for stacking blocks:


var Drone = require('../drone').Drone;
var blocks = require('blocks');

function tumpuk( tingkat ) {
echo(tingkat);
this.chkpt('tumpuk');
for (var i = 0; i < tingkat; i++){
this.up(1).box0('35:6',1, 1, 1);
}

this.move('tumpuk');
};

Drone.extend(tumpuk);

type it on the command line:

Tangkapan layar 2015-03-10 20.17.44

and you will get this:

Tangkapan layar 2015-03-10 20.18.10

If you modify the code and want to re-run it on Minecraft, just type ‘reload’ or /js refresh() on the command prompt.

Next time we will learn to build awesome buildings like pyramid or maybe rocket launcher! 😉

7 thoughts on “Minecraft Programming – Creating Buildings with ScriptCraft Functions on CanaryMod

Leave a comment