From 2f2db3c76f84b15ee57ce966d7e76328b0fa481f Mon Sep 17 00:00:00 2001 From: walterhiggins Date: Sat, 24 May 2014 10:55:27 +0100 Subject: [PATCH] Added new blocks. and changed Drone.extend to support single param. --- src/main/js/modules/blocks.js | 4 +++- src/main/js/modules/items.js | 5 +++-- src/main/js/plugins/drone/contrib/temple.js | 12 +++++++++--- src/main/js/plugins/drone/drone.js | 21 +++++++++++++++++++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/main/js/modules/blocks.js b/src/main/js/modules/blocks.js index ae4fcd8..5b96cf3 100644 --- a/src/main/js/modules/blocks.js +++ b/src/main/js/modules/blocks.js @@ -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 diff --git a/src/main/js/modules/items.js b/src/main/js/modules/items.js index 080a9a6..a3b60cd 100644 --- a/src/main/js/modules/items.js +++ b/src/main/js/modules/items.js @@ -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); }; diff --git a/src/main/js/plugins/drone/contrib/temple.js b/src/main/js/plugins/drone/contrib/temple.js index 82d52c7..8545e60 100644 --- a/src/main/js/plugins/drone/contrib/temple.js +++ b/src/main/js/plugins/drone/contrib/temple.js @@ -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'); }); diff --git a/src/main/js/plugins/drone/drone.js b/src/main/js/plugins/drone/drone.js index b478cb2..bd04253 100644 --- a/src/main/js/plugins/drone/drone.js +++ b/src/main/js/plugins/drone/drone.js @@ -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 ) {