Saturday, February 23, 2013

Build Giant Ravine in Minecraft using ScriptCraft (with other examples)

Minecraft is a huge game.  The full PC version is especially great because it is customizable with lots of mods available all over the internet.  One great new mod is ScriptCraft by Walter Higgins (http://scriptcraftjs.org/). ScriptCraft runs on a bukkit version of the minecraft server.  Installation is covered on the ServerCraft site.

ScriptCraft adds javascript control of minecraft.  Buildings and other objects can be created instantly through the Minecraft command line.  Also this can be a great way to introduce someone into programming for the first time.

Try these samples below.  Copy these javascript sources to your server and restart it to try them out.

Save as igloo.js and put in your js-plugins\drone folder.


load(__folder + "drone.js")
//
// constructs an igloo
//
Drone.extend('igloo', function () {
this.chkpt('igloo');
//make basic structure
this.hemisphere0(blocks.snow, 7, 'north');
this.right(2).down(2);
//clear door
this.back();
this.right(4);
this.up(2);
this.box(0, 2, 3, 2);
return this.move('igloo');
});


Run this by typing in the Minecraft command line


/js igloo()




Save as enchant_table.js and put in your js-plugins\drone folder.


load(__folder + "drone.js")
//
// constructs an enchantment table surrounded with books for max enchanting
//
Drone.extend('enchant_table', function () {
this.up(); //set to just above floor level.
this.box0(blocks.bookshelf, 5, 5, 4);
this.chkpt('enchant_table');
//open side
this.up().right();
this.box0(0, 3, 3, 1);
//add enchantment table
this.move('enchant_table');
this.up().fwd().right(2);
this.box(blocks.table_enchantment);
//add floor
this.move('enchant_table');
this.box(blocks.bookshelf, 5, 1, 4);
//add roof
this.up(4);
this.box(blocks.bookshelf, 5, 1, 4);

return this;
});

Run this by typing in the Minecraft command line


/js enchant_table()


Now you'll have a enchantment table that is fully maxed out.

One of my favorite things to do with this is to use the command to explore and reveal to world underneath.  So to clear out large areas in this snow covered forest, issue a command like down(height/2).box(blocktype, width, height, depth) with 0 for the block type.





/js down(40).box(0, 20, 70, 120)




Now just look at the giant ravine we've created.  This method reveals all sort of neat areas to explore and is great for mining.

The box(...) part of the function is what actually clears the area out since we are using air (block 0) as the block.  Since box() always goes up, we need to send the command down with the down(40) command first.  Since we are using javascript we can chain the commands together as shown above.

What kind of cool things are you doing?  Please send me a note if you've enjoyed this page.

Some of the ScriptCraft built in samples to try:
/js castle()
/js chessboard()
/js cottage()
/js cottage_road()
/js dancefloor()
/js fort()
/js rainbow()
/js temple()

To create with other block types, use the (dec) values from the official Minecraft list:
http://www.minecraftwiki.net/wiki/Data_values