Added new blocks. and changed Drone.extend to support single param.

This commit is contained in:
walterhiggins 2014-05-24 10:55:27 +01:00
parent c324adf269
commit 2f2db3c76f
4 changed files with 34 additions and 8 deletions

View file

@ -230,7 +230,9 @@ var blocks = {
white: 171 // All other colors added below
},
hardened_clay: 172,
coal_block: 173
coal_block: 173,
packed_ice: 174,
double_plant: 175
};
// Add all available colors to colorized block collections

View file

@ -1,6 +1,7 @@
var bkItemStack = org.bukkit.inventory.ItemStack,
bkMaterial = org.bukkit.Material
var items = function(material, amount){
bkMaterial = org.bukkit.Material;
var items = function( material, amount ) {
material = material.toUpperCase();
return new bkItemStack(bkMaterial[material],amount);
};

View file

@ -15,10 +15,16 @@ Drone.extend('temple', function(side) {
var middle = Math.round( (side-2) / 2 );
this.chkpt('corner')
.box( stone, side, 1, side )
.right( middle ).box( stair ).right().box( stair )
.move('corner').up().fwd().right();
.right( middle )
.box( stair )
.right()
.box( stair )
.move('corner')
.up()
.fwd()
.right();
side = side - 2;
}
return this.move('temple');
this.move('temple');
});

View file

@ -582,10 +582,13 @@ Use this method to add new methods (which also become chainable global functions
#### Parameters
* name - The name of the new method e.g. 'pyramid'
* name - The name of the new method e.g. 'pyramid'.
* function - The method body.
#### Example
Alternatively if you provide just a function as a parameter, then the function name will be used as the new method name. For example the following two approaches are both valid.
#### Example 1 Using name and function as parameters
// submitted by [edonaldson][edonaldson]
Drone.extend('pyramid', function( block,height) {
@ -596,6 +599,16 @@ Use this method to add new methods (which also become chainable global functions
return this.move('pyramid');
});
#### Example 2 Using just a named function as a parameter
Drone.extend(function pyramid( block,height) {
this.chkpt('pyramid');
for ( var i = height; i > 0; i -= 2) {
this.box(block, i, 1, i).up().right().fwd();
}
return this.move('pyramid');
});
Once the method is defined (it can be defined in a new pyramid.js file) it can be used like so...
var d = new Drone();
@ -790,6 +803,10 @@ addUnloadHandler( function() {
// add custom methods to the Drone object using this function
//
Drone.extend = function( name, func ) {
if (arguments.length == 1){
func = name;
name = func.name;
}
Drone.prototype[ '_' + name ] = func;
Drone.prototype[ name ] = function( ) {
if ( this.record ) {