This commit is contained in:
walterhiggins 2015-01-16 21:20:34 +00:00
parent 52e198bb2e
commit ed8782873a
22 changed files with 716 additions and 164 deletions

View file

@ -371,8 +371,20 @@ Walter Higgins
* [Drone.hemisphere0() method](#dronehemisphere0-method) * [Drone.hemisphere0() method](#dronehemisphere0-method)
* [Drone.stairs() function](#dronestairs-function) * [Drone.stairs() function](#dronestairs-function)
* [Drone Trees methods](#drone-trees-methods) * [Drone Trees methods](#drone-trees-methods)
* [Drone.castle() method](#dronecastle-method)
* [Drone.chessboard() method](#dronechessboard-method)
* [Drone.cottage() method](#dronecottage-method)
* [Drone.cottage_road() method](#dronecottage_road-method)
* [Drone.dancefloor() method](#dronedancefloor-method)
* [Parameters](#parameters)
* [Drone.fort() method](#dronefort-method)
* [Drone.hangtorch() method](#dronehangtorch-method)
* [Drone.lcdclock() method.](#dronelcdclock-method)
* [Drone.logojs() method](#dronelogojs-method)
* [Drone.maze() method](#dronemaze-method)
* [Drone.rainbow() method](#dronerainbow-method) * [Drone.rainbow() method](#dronerainbow-method)
* [Drone.spiral_stairs() method](#dronespiral_stairs-method) * [Drone.spiral_stairs() method](#dronespiral_stairs-method)
* [Drone.temple() method](#dronetemple-method)
* [Blocks Module](#blocks-module) * [Blocks Module](#blocks-module)
* [Examples](#examples) * [Examples](#examples)
* [Fireworks Module](#fireworks-module) * [Fireworks Module](#fireworks-module)
@ -3637,7 +3649,7 @@ Creates the text out of blocks. Useful for large-scale in-game signs.
To create a 2-line high message using glowstone... To create a 2-line high message using glowstone...
blocktype("Hello\nWorld",blocks.glowstone); blocktype('Hello\nWorld', blocks.glowstone);
![blocktype example][imgbt1] ![blocktype example][imgbt1]
@ -4099,6 +4111,243 @@ None of the tree methods require parameters. Tree methods will only be
successful if the tree is placed on grass in a setting where trees can successful if the tree is placed on grass in a setting where trees can
grow. grow.
### Drone.castle() method
Creates a Castle. A castle is just a big wide fort with 4 taller forts at each corner.
See also Drone.fort() method.
#### Parameters
* side - How many blocks wide and long the castle will be (default: 24. Must be greater than 19)
* height - How tall the castle will be (default: 10. Must be geater than 7)
#### Example
At the in-game prompt you can create a castle by looking at a block and typing:
```javascript
/js castle()
```
Alternatively you can create a new Drone object from a Player or Location object and call the castle() method.
```javascript
var d = new Drone(player);
d.castle();
```
![castle example](img/castleex1.png)
### Drone.chessboard() method
Creates a tile pattern of given block types and size
#### Parameters
* whiteBlock - (optional: default blocks.wool.white)
* blackBlock - (optional: default blocks.wool.black)
* width - width of the chessboard
* length - length of the chessboard
#### Example
At the in-game prompt you can create a chessboard by looking at a block and typing:
```javascript
/js chessboard()
```
Alternatively you can create a new Drone object from a Player or Location object and call the chessboard() method.
```javascript
var d = new Drone(player);
d.chessboard();
```
![chessboard example](img/chessboardex1.png)
### Drone.cottage() method
Creates a simple but cosy dwelling.
#### Example
At the in-game prompt you can create a cottage by looking at a block and typing:
```javascript
/js cottage()
```
Alternatively you can create a new Drone object from a Player or Location object and call the cottage() method.
```javascript
var d = new Drone(player);
d.cottage();
```
![cottage example](img/cottageex1.png)
### Drone.cottage_road() method
Creates a tree-lined avenue with cottages on both sides.
#### Parameters
* numberOfCottages: The number of cottages to build in total (optional: default 6)
#### Example
At the in-game prompt you can create a cottage road by looking at a block and typing:
```javascript
/js cottage_road()
```
Alternatively you can create a new Drone object from a Player or Location object and call the cottage_road() method.
```javascript
var d = new Drone(player);
d.cottage_road();
```
![cottage_road example](img/cottageroadex1.png)
### Drone.dancefloor() method
Create an animated dance floor of colored tiles some of which emit light.
The tiles change color every second creating a strobe-lit dance-floor effect.
See it in action here [http://www.youtube.com/watch?v=UEooBt6NTFo][ytdance]
### Parameters
* width - how wide the dancefloor should be (optional: default 5)
* length - how long the dancefloor should be (optional: default 5)
* duration - the time duration for which the lights should change (optional: default 30 seconds)
#### Example
At the in-game prompt you can create a dancefloor by looking at a block and typing:
```javascript
/js dancefloor()
```
Alternatively you can create a new Drone object from a Player or Location object and call the dancefloor() method.
```javascript
var d = new Drone(player);
d.dancefloor();
```
[ytdance]: http://www.youtube.com/watch?v=UEooBt6NTFo
![dancefloor example](img/dancefloorex1.png)
### Drone.fort() method
Constructs a medieval fort.
#### Parameters
* side - How many blocks whide and long the fort will be (default: 18 . Must be greater than 9)
* height - How tall the fort will be (default: 6 . Must be greater than 3)
#### Example
At the in-game prompt you can create a fort by looking at a block and typing:
```javascript
/js fort()
```
Alternatively you can create a new Drone object from a Player or Location object and call the fort() method.
```javascript
var d = new Drone(player);
d.fort();
```
![fort example](img/fortex1.png)
### Drone.hangtorch() method
Adds a hanging torch to a wall. This method will try to hang a torch
against a wall. It will traverse backwards until it finds a block
adjacent to air and hang the torch. If it can't find a block next to
air it will log a message in the server.
#### Example
At the in-game prompt you can create a hanging torch by looking at a
block and typing:
```javascript
/js hangtorch()
```
Alternatively you can create a new Drone object from a Player or
Location object and call the hangtorch() method.
```javascript
var d = new Drone(player);
d.hangtorch();
```
### Drone.lcdclock() method.
Constructs a large LCD Clock. The clock will display the current time of day.
The clock can be stopped by calling the stopLCD() method of the Drone which created the clock.
#### Parameters
* foregroundBlock (Optional - default is blocks.glowstone)
* backgroundBlock (Optional - default is blocks.wool.black)
* borderBlock (Optional - a border around the LCD display - default none)
#### Example
At the in-game prompt you can create a LCD clock by looking at a block and typing:
```javascript
/js var clock = lcdclock()
/js clock.stopLCD()
```
Alternatively you can create a new Drone object from a Player or Location object and call the lcdclock() method.
```javascript
var d = new Drone(player);
d.lcdclock();
d.stopLCD();
```
![lcdclock example](img/lcdclockex1.png)
### Drone.logojs() method
Constructs a large Javascript Logo (black JS on Yellow background)
See: https://raw.github.com/voodootikigod/logo.js/master/js.png
#### Parameters
* foregroundBlock (Optional - default is blocks.wool.gray)
* backgroundBlock (Optional - default is blocks.gold)
### Drone.maze() method
Maze generation based on http://rosettacode.org/wiki/Maze_generation#JavaScript
#### Parameters
* width (optional - default 10)
* length (optional - default 10)
#### Example
At the in-game prompt you can create a maze by looking at a block and typing:
```javascript
/js maze()
```
Alternatively you can create a new Drone object from a Player or Location object and call the maze() method.
```javascript
var d = new Drone(player);
d.maze();
```
![maze example](img/mazeex1.png)
### Drone.rainbow() method ### Drone.rainbow() method
Creates a Rainbow. Creates a Rainbow.
@ -4109,8 +4358,17 @@ Creates a Rainbow.
#### Example #### Example
var d = new Drone(); At the in-game prompt you can create a rainbow by looking at a block and typing:
d.rainbow(30); ```javascript
/js rainbow()
```
Alternatively you can create a new Drone object from a Player or Location object and call the rainbow() method.
```javascript
var d = new Drone(player);
d.rainbow(30);
```
![rainbow example](img/rainbowex1.png) ![rainbow example](img/rainbowex1.png)
@ -4141,6 +4399,30 @@ To construct a spiral staircase 5 floors high made of oak...
spiral_stairs('oak', 5); spiral_stairs('oak', 5);
### Drone.temple() method
Constructs a mayan temple.
#### Parameters
* side - How many blocks wide and long the temple will be (default: 20)
#### Example
At the in-game prompt you can create a temple by looking at a block and typing:
```javascript
/js temple()
```
Alternatively you can create a new Drone object from a Player or Location object and call the temple() method.
```javascript
var d = new Drone(player);
d.temple();
```
![temple example](img/templeex1.png)
## Blocks Module ## Blocks Module
You hate having to lookup [Data Values][dv] when you use ScriptCraft's You hate having to lookup [Data Values][dv] when you use ScriptCraft's

BIN
docs/img/castleex1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 KiB

BIN
docs/img/chessboardex1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

BIN
docs/img/cottageex1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

BIN
docs/img/cottageroadex1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

BIN
docs/img/dancefloorex1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

BIN
docs/img/fortex1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

BIN
docs/img/lcdclockex1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

BIN
docs/img/mazeex1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB

BIN
docs/img/templeex1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 KiB

View file

@ -15,7 +15,7 @@ Creates the text out of blocks. Useful for large-scale in-game signs.
To create a 2-line high message using glowstone... To create a 2-line high message using glowstone...
blocktype("Hello\nWorld",blocks.glowstone); blocktype('Hello\nWorld', blocks.glowstone);
![blocktype example][imgbt1] ![blocktype example][imgbt1]

View file

@ -1,22 +1,46 @@
var Drone = require('drone'); 'use strict';
// /*global require */
// a castle is just a big wide fort with 4 taller forts at each corner var Drone = require('drone'),
// blocks = require('blocks');
/************************************************************************
### Drone.castle() method
Creates a Castle. A castle is just a big wide fort with 4 taller forts at each corner.
See also Drone.fort() method.
#### Parameters
* side - How many blocks wide and long the castle will be (default: 24. Must be greater than 19)
* height - How tall the castle will be (default: 10. Must be geater than 7)
#### Example
At the in-game prompt you can create a castle by looking at a block and typing:
```javascript
/js castle()
```
Alternatively you can create a new Drone object from a Player or Location object and call the castle() method.
```javascript
var d = new Drone(player);
d.castle();
```
![castle example](img/castleex1.png)
***/
function castle( side, height ) { function castle( side, height ) {
// //
// use sensible default parameter values // use sensible default parameter values
// if no parameters are supplied // if no parameters are supplied
// //
if ( typeof side == "undefined" ) if ( typeof side == 'undefined' )
side = 24; side = 24;
if ( typeof height == "undefined" ) if ( typeof height == 'undefined' )
height = 10; height = 10;
if ( height < 8 || side < 20 ) if ( height < 8 || side < 20 )
throw new java.lang.RuntimeException("Castles must be at least 20 wide X 8 tall"); throw new java.lang.RuntimeException('Castles must be at least 20 wide X 8 tall');
//
// remember where the drone is so it can return 'home'
//
this.chkpt('castle');
// //
// how big the towers at each corner will be... // how big the towers at each corner will be...
// //
@ -26,32 +50,31 @@ function castle( side, height ) {
// //
// the main castle building will be front and right of the first tower // the main castle building will be front and right of the first tower
// //
this.fwd(towerSide/2).right(towerSide/2); this
// .chkpt('castle')
// the castle is really just a big fort with 4 smaller 'tower' forts at each corner .fwd( towerSide / 2 )
// .right( towerSide / 2 )
this.fort(side,height); .fort( side, height )
// .move( 'castle' );
// move back to start position
//
this.move('castle');
// //
// now place 4 towers at each corner (each tower is another fort) // now place 4 towers at each corner (each tower is another fort)
// //
for ( var corner = 0; corner < 4; corner++ ) { for ( var corner = 0; corner < 4; corner++ ) {
// construct a 'tower' fort // construct a 'tower' fort
this.fort(towerSide,towerHeight); this
this.chkpt('tower-' + corner); .fort( towerSide, towerHeight )
// create 2 doorways from main castle rampart into each tower .chkpt('tower-' + corner)
this.fwd(towerSide-1).right(towerSide-3).up(towerHeight-5); .fwd( towerSide - 1 )
this.box(blocks.air, 1,2,1); .right( towerSide - 3 )
this.back(2).right(2); .up( towerHeight - 5 ) // create 2 doorways from main castle rampart into each tower
this.box(blocks.air, 1,2,1); .box( blocks.air, 1, 2, 1 )
.back( 2 )
this.move('tower-' + corner); .right( 2 )
// move forward the length of the castle then turn right .box( blocks.air, 1, 2, 1 )
this.fwd(side+towerSide-1).turn(); .move( 'tower-' + corner)
.fwd( side + towerSide - 1) // move forward the length of the castle then turn right
.turn();
} }
return this.move('castle'); this.move('castle');
} }
Drone.extend(castle); Drone.extend(castle);

View file

@ -1,21 +1,41 @@
var Drone = require('drone'); 'use strict';
var blocks = require('blocks'); /*global require */
var Drone = require('drone'),
blocks = require('blocks');
/************************************************************************
### Drone.chessboard() method
/** Creates a tile pattern of given block types and size
* Creates a tile pattern of given block types and size
* #### Parameters
* Paramters:
* whiteBlock - blockId used for the traditional white portion of the chessboard * whiteBlock - (optional: default blocks.wool.white)
* blackBlock - blockId used for the traditional black portion of the chessboard * blackBlock - (optional: default blocks.wool.black)
* width - width of the chessboard * width - width of the chessboard
* height - height of the chessboard * length - length of the chessboard
*/
#### Example
At the in-game prompt you can create a chessboard by looking at a block and typing:
```javascript
/js chessboard()
```
Alternatively you can create a new Drone object from a Player or Location object and call the chessboard() method.
```javascript
var d = new Drone(player);
d.chessboard();
```
![chessboard example](img/chessboardex1.png)
***/
Drone.extend('chessboard', function( whiteBlock, blackBlock, width, depth ) { Drone.extend('chessboard', function( whiteBlock, blackBlock, width, depth ) {
var i, var i,
j, j,
block; block;
this.chkpt('chessboard-start');
if ( typeof whiteBlock == 'undefined' ) { if ( typeof whiteBlock == 'undefined' ) {
whiteBlock = blocks.wool.white; whiteBlock = blocks.wool.white;
@ -29,10 +49,12 @@ Drone.extend('chessboard', function( whiteBlock, blackBlock, width, depth ) {
if ( typeof depth == 'undefined' ) { if ( typeof depth == 'undefined' ) {
depth = width; depth = width;
} }
var wb = [ blackBlock, whiteBlock ]; var squares = [ blackBlock, whiteBlock ];
this.chkpt('chessboard-start');
for ( i = 0; i < depth; i++ ) { for ( i = 0; i < depth; i++ ) {
this.boxa( wb, width, 1, 1).fwd(); this.boxa( squares, width, 1, 1).fwd();
wb = wb.reverse(); squares = squares.reverse();
} }
return this.move('chessboard-start'); this.move('chessboard-start');
}); });

View file

@ -1,15 +1,29 @@
var Drone = require('drone'); 'use strict';
var blocks = require('blocks'); /*global require */
// var Drone = require('drone'),
// usage: blocks = require('blocks');
// [1] to build a cottage at the player's current location or the cross-hairs location... /************************************************************************
// ### Drone.cottage() method
// /js cottage();
// Creates a simple but cosy dwelling.
// [2] to build a cottage using an existing drone...
// #### Example
// /js drone.cottage();
// At the in-game prompt you can create a cottage by looking at a block and typing:
```javascript
/js cottage()
```
Alternatively you can create a new Drone object from a Player or Location object and call the cottage() method.
```javascript
var d = new Drone(player);
d.cottage();
```
![cottage example](img/cottageex1.png)
***/
function cottage( ) { function cottage( ) {
this this
.chkpt('cottage') .chkpt('cottage')
@ -48,6 +62,33 @@ function cottage( ) {
.move('cottage') .move('cottage')
; ;
} }
/************************************************************************
### Drone.cottage_road() method
Creates a tree-lined avenue with cottages on both sides.
#### Parameters
* numberOfCottages: The number of cottages to build in total (optional: default 6)
#### Example
At the in-game prompt you can create a cottage road by looking at a block and typing:
```javascript
/js cottage_road()
```
Alternatively you can create a new Drone object from a Player or Location object and call the cottage_road() method.
```javascript
var d = new Drone(player);
d.cottage_road();
```
![cottage_road example](img/cottageroadex1.png)
***/
// //
// a more complex script that builds an tree-lined avenue with // a more complex script that builds an tree-lined avenue with
// cottages on both sides. // cottages on both sides.
@ -62,11 +103,15 @@ function cottage_road( numberCottages ) {
// //
var cottagesPerSide = Math.floor(numberCottages/2); var cottagesPerSide = Math.floor(numberCottages/2);
this this
.chkpt('cottage_road') // make sure the drone's state is saved. // make sure the drone's state is saved.
.box( blocks.double_slab.stone, 3, 1, cottagesPerSide * ( distanceBetweenTrees + 1 ) ) // build the road .chkpt('cottage_road')
// build the road
.box( blocks.double_slab.stone, 3, 1, cottagesPerSide * ( distanceBetweenTrees + 1 ) )
.up() .up()
.right() // now centered in middle of road // now centered in middle of road
.chkpt('cr'); // will be returning to this position later .right()
// will be returning to this position later
.chkpt('cottage_road_cr');
// //
// step 2 line the road with trees // step 2 line the road with trees
@ -81,7 +126,7 @@ function cottage_road( numberCottages ) {
.fwd( distanceBetweenTrees + 1 ); // move forward. .fwd( distanceBetweenTrees + 1 ); // move forward.
} }
this this
.move('cr') .move('cottage_road_cr')
.back(6); // move back 1/2 the distance between trees .back(6); // move back 1/2 the distance between trees
// this function builds a path leading to a cottage. // this function builds a path leading to a cottage.

View file

@ -1,17 +1,50 @@
var Drone = require('drone'); 'use strict';
var blocks = require('blocks'); /*global require, clearInterval, setInterval*/
var Drone = require('drone'),
blocks = require('blocks'),
SECOND = 1000;
/************************************************************************
### Drone.dancefloor() method
Create an animated dance floor of colored tiles some of which emit light.
The tiles change color every second creating a strobe-lit dance-floor effect.
See it in action here [http://www.youtube.com/watch?v=UEooBt6NTFo][ytdance]
### Parameters
* width - how wide the dancefloor should be (optional: default 5)
* length - how long the dancefloor should be (optional: default 5)
* duration - the time duration for which the lights should change (optional: default 30 seconds)
#### Example
At the in-game prompt you can create a dancefloor by looking at a block and typing:
```javascript
/js dancefloor()
```
Alternatively you can create a new Drone object from a Player or Location object and call the dancefloor() method.
```javascript
var d = new Drone(player);
d.dancefloor();
```
[ytdance]: http://www.youtube.com/watch?v=UEooBt6NTFo
![dancefloor example](img/dancefloorex1.png)
***/
// //
// Create a floor of colored tiles some of which emit light. function dancefloor(width, length, duration)
// The tiles change color every second creating a strobe-lit dance-floor.
//
// See it in action here => http://www.youtube.com/watch?v=UEooBt6NTFo
//
function dancefloor(width,length)
{ {
if (typeof width == "undefined") if (typeof width == 'undefined')
width = 5; width = 5;
if (typeof length == "undefined") if (typeof length == 'undefined')
length = width; length = width;
if (typeof duration === 'undefined'){
duration = 30;
}
// //
// create a separate Drone object to lay down disco tiles // create a separate Drone object to lay down disco tiles
// //
@ -19,22 +52,23 @@ function dancefloor(width,length)
// //
// under-floor lighting // under-floor lighting
// //
disco.down().box(89,width,1,length).up(); disco
var floorTiles = [35,35,'35:1','35:2','35:3','35:4','35:4','35:4','35:6',20,20]; .down()
.box( blocks.glowstone, width, 1, length)
.up();
// //
// strobe gets called in a java thread - disco only lasts 30 seconds. // strobe gets called in a java thread - disco only lasts 30 seconds.
// //
var discoTicks = 30;
var task = null; var task = null;
var strobe = function() { var strobe = function() {
disco.rand(blocks.rainbow ,width,1,length); disco.rand(blocks.rainbow, width, 1, length);
if (!discoTicks--) duration--;
if ( duration == 0 ){
// turn off the lights
clearInterval(task); clearInterval(task);
}
}; };
var now = 0; task = setInterval( strobe, 1 * SECOND);
var everySecond = 20;
task = setInterval( strobe, 1000);
return this;
} }
Drone.extend(dancefloor); Drone.extend( dancefloor );

View file

@ -1,9 +1,34 @@
'use strict'; 'use strict';
var Drone = require('drone'); /*global require */
var blocks = require('blocks'); var Drone = require('drone'),
// blocks = require('blocks');
// constructs a medieval fort /************************************************************************
// ### Drone.fort() method
Constructs a medieval fort.
#### Parameters
* side - How many blocks whide and long the fort will be (default: 18 . Must be greater than 9)
* height - How tall the fort will be (default: 6 . Must be greater than 3)
#### Example
At the in-game prompt you can create a fort by looking at a block and typing:
```javascript
/js fort()
```
Alternatively you can create a new Drone object from a Player or Location object and call the fort() method.
```javascript
var d = new Drone(player);
d.fort();
```
![fort example](img/fortex1.png)
***/
function fort( side, height ) { function fort( side, height ) {
var turret, var turret,
i, i,
@ -65,9 +90,9 @@ function fort( side, height ) {
.right(); .right();
for ( i = 0; i < battlementWidth; i++ ) { for ( i = 0; i < battlementWidth; i++ ) {
var bside = side - ( 2 + (i * 2) );
this this
.box0(blocks.slab.oak, side - ( 2 + (i * 2) ), 1, side - ( 2 + ( i * 2) )) .box0( blocks.slab.oak, bside, 1, bside)
.fwd() .fwd()
.right(); .right();
} }
@ -77,25 +102,25 @@ function fort( side, height ) {
torch = blocks.torch + ':' + Drone.PLAYER_TORCH_FACING[this.dir]; torch = blocks.torch + ':' + Drone.PLAYER_TORCH_FACING[this.dir];
this this
.move('fort') .move('fort')
.right((side/2)-1) .right( ( side / 2 ) - 1 )
.door2() // double doors .door2() // double doors
.back() .back()
.left() .left()
.up() .up()
.box(torch) // left torch .box( torch ) // left torch
.right(3) .right( 3 )
.box(torch); // right torch .box( torch ); // right torch
// //
// add ladder up to battlements // add ladder up to battlements
// //
this this
.move('fort') .move('fort')
.right((side/2)-3) .right( ( side / 2 ) - 3 )
.fwd(1) // move inside fort .fwd() // move inside fort
.turn(2) .turn( 2 )
.box(blocks.air, 1, height-1, 1) .box( blocks.air, 1, height - 1, 1)
.ladder(height-1) .ladder( height - 1 )
.move('fort'); .move( 'fort' );
} }
Drone.extend(fort); Drone.extend(fort);

View file

@ -1,12 +1,37 @@
'use strict'; 'use strict';
/*global require, __plugin, org*/ /*global require, __plugin, org*/
var Drone = require('drone'), var Drone = require('drone'),
bkMaterial = org.bukkit.Material,
blocks = require('blocks'); blocks = require('blocks');
/************************************************************************
### Drone.hangtorch() method
Adds a hanging torch to a wall. This method will try to hang a torch
against a wall. It will traverse backwards until it finds a block
adjacent to air and hang the torch. If it can't find a block next to
air it will log a message in the server.
#### Example
At the in-game prompt you can create a hanging torch by looking at a
block and typing:
```javascript
/js hangtorch()
```
Alternatively you can create a new Drone object from a Player or
Location object and call the hangtorch() method.
```javascript
var d = new Drone(player);
d.hangtorch();
```
***/
function canHang( block ) { function canHang( block ) {
if (__plugin.bukkit){ if (__plugin.bukkit){
var bkMaterial = org.bukkit.Material;
if ( block.type.equals(bkMaterial.AIR) || if ( block.type.equals(bkMaterial.AIR) ||
block.type.equals(bkMaterial.VINE) ) { block.type.equals(bkMaterial.VINE) ) {
return true; return true;

View file

@ -1,20 +1,39 @@
'use strict'; 'use strict';
/*global require, setInterval, clearInterval, __plugin, exports*/ /*global require, setInterval, clearInterval, __plugin, exports*/
/* /*************************************************************************
Point at a block and issue the following ... ### Drone.lcdclock() method.
/js var d = new Drone();
/js var clock = new LCDClock(d); Constructs a large LCD Clock. The clock will display the current time of day.
/js clock.start24(); The clock can be stopped by calling the stopLCD() method of the Drone which created the clock.
... start the clock...
/js clock.stop24(); #### Parameters
... stops the clock...
*/ * foregroundBlock (Optional - default is blocks.glowstone)
* backgroundBlock (Optional - default is blocks.wool.black)
* borderBlock (Optional - a border around the LCD display - default none)
#### Example
At the in-game prompt you can create a LCD clock by looking at a block and typing:
```javascript
/js var clock = lcdclock()
/js clock.stopLCD()
```
Alternatively you can create a new Drone object from a Player or Location object and call the lcdclock() method.
```javascript
var d = new Drone(player);
d.lcdclock();
d.stopLCD();
```
![lcdclock example](img/lcdclockex1.png)
***/
var blocks = require('blocks'), var blocks = require('blocks'),
utils = require('utils'), utils = require('utils'),
Drone = require('drone'); Drone = require('drone');
Drone.extend(lcdclock);
function lcdclock(fgColor, bgColor, border){ function lcdclock(fgColor, bgColor, border){
var drone = this; var drone = this;
var lastSecs = [0,0,0,0], var lastSecs = [0,0,0,0],
@ -78,6 +97,9 @@ function lcdclock(fgColor, bgColor, border){
update( timeOfDayInMins ); update( timeOfDayInMins );
} }
intervalId = setInterval(tick, 800); intervalId = setInterval(tick, 800);
console.log('lcdclock started background task:' + intervalId); this.stopLCD = function(){
clearInterval(intervalId);
};
} }
Drone.extend(lcdclock);

View file

@ -2,16 +2,18 @@
/*global require*/ /*global require*/
var Drone = require('drone'), var Drone = require('drone'),
blocks = require('blocks'); blocks = require('blocks');
/************************************************************************
### Drone.logojs() method
// Constructs a large Javascript Logo (black JS on Yellow background)
// Constructs the JS logo See: https://raw.github.com/voodootikigod/logo.js/master/js.png
// https://raw.github.com/voodootikigod/logo.js/master/js.png
// #### Parameters
// fg
// the material that the letters JS will be made of * foregroundBlock (Optional - default is blocks.wool.gray)
// bg * backgroundBlock (Optional - default is blocks.gold)
// the material that the square will be made of
// ***/
function logojs(fg, bg) { function logojs(fg, bg) {
// foreground defaults to gray wool // foreground defaults to gray wool

View file

@ -1,10 +1,45 @@
// Maze generation based on http://rosettacode.org/wiki/Maze_generation#JavaScript 'use strict';
/*global require*/
/************************************************************************
### Drone.maze() method
Maze generation based on http://rosettacode.org/wiki/Maze_generation#JavaScript
#### Parameters
* width (optional - default 10)
* length (optional - default 10)
#### Example
At the in-game prompt you can create a maze by looking at a block and typing:
```javascript
/js maze()
```
Alternatively you can create a new Drone object from a Player or Location object and call the maze() method.
```javascript
var d = new Drone(player);
d.maze();
```
![maze example](img/mazeex1.png)
***/
var Drone = require('drone'),
blocks = require('blocks');
var Drone = require('drone');
// User-facing code starts here // User-facing code starts here
// Example: Try /js maze(5,7) // Example: Try /js maze(5,7)
Drone.extend( function maze( size_x, size_y ) { Drone.extend( function maze( width, length ) {
m = maze_make(size_x, size_y); if (typeof width === 'undefined'){
width = 10;
}
if (typeof length === 'undefined'){
length = 10;
}
var m = maze_make(width, length);
if (m.x > 0 && m.y > 0) { if (m.x > 0 && m.y > 0) {
maze_draw(maze_display(m), this); maze_draw(maze_display(m), this);
} }
@ -15,15 +50,18 @@ Drone.extend( function maze( size_x, size_y ) {
function maze_make(x,y) { function maze_make(x,y) {
var n=x*y-1; var n=x*y-1;
if (n<0) { if (n<0) {
echo("illegal maze dimensions"); console.log ("illegal maze dimensions");
return ({x: 0, y: 0}); return ({x: 0, y: 0});
} }
var horiz=[]; for (var j= 0; j<x+1; j++) horiz[j]= []; var horiz=[];
var verti=[]; for (var j= 0; j<y+1; j++) verti[j]= []; var j;
for ( j = 0; j<x+1; j++) horiz[j]= [];
var verti=[];
for ( j = 0; j<y+1; j++) verti[j]= [];
var here= [Math.floor(Math.random()*x), Math.floor(Math.random()*y)]; var here= [Math.floor(Math.random()*x), Math.floor(Math.random()*y)];
var path= [here]; var path= [here];
var unvisited= []; var unvisited= [];
for (var j= 0; j<x+2; j++) { for (j = 0; j<x+2; j++) {
unvisited[j]= []; unvisited[j]= [];
for (var k= 0; k<y+1; k++) for (var k= 0; k<y+1; k++)
unvisited[j].push(j>0 && j<x+1 && k>0 && (j != here[0]+1 || k != here[1]+1)); unvisited[j].push(j>0 && j<x+1 && k>0 && (j != here[0]+1 || k != here[1]+1));
@ -32,12 +70,12 @@ function maze_make(x,y) {
var potential= [[here[0]+1, here[1]], [here[0],here[1]+1], var potential= [[here[0]+1, here[1]], [here[0],here[1]+1],
[here[0]-1, here[1]], [here[0],here[1]-1]]; [here[0]-1, here[1]], [here[0],here[1]-1]];
var neighbors= []; var neighbors= [];
for (var j= 0; j < 4; j++) for (j= 0; j < 4; j++)
if (unvisited[potential[j][0]+1][potential[j][1]+1]) if (unvisited[potential[j][0]+1][potential[j][1]+1])
neighbors.push(potential[j]); neighbors.push(potential[j]);
if (neighbors.length) { if (neighbors.length) {
n= n-1; n= n-1;
next= neighbors[Math.floor(Math.random()*neighbors.length)]; var next= neighbors[Math.floor(Math.random()*neighbors.length)];
unvisited[next[0]+1][next[1]+1]= false; unvisited[next[0]+1][next[1]+1]= false;
if (next[0] == here[0]) if (next[0] == here[0])
horiz[next[0]][(next[1]+here[1]-1)/2]= true; horiz[next[0]][(next[1]+here[1]-1)/2]= true;

View file

@ -14,8 +14,17 @@ Creates a Rainbow.
#### Example #### Example
var d = new Drone(); At the in-game prompt you can create a rainbow by looking at a block and typing:
d.rainbow(30); ```javascript
/js rainbow()
```
Alternatively you can create a new Drone object from a Player or Location object and call the rainbow() method.
```javascript
var d = new Drone(player);
d.rainbow(30);
```
![rainbow example](img/rainbowex1.png) ![rainbow example](img/rainbowex1.png)

View file

@ -1,8 +1,33 @@
'use strict';
/*global require*/
var Drone = require('drone'), var Drone = require('drone'),
blocks = require('blocks'); blocks = require('blocks');
// /************************************************************************
// constructs a mayan temple ### Drone.temple() method
//
Constructs a mayan temple.
#### Parameters
* side - How many blocks wide and long the temple will be (default: 20)
#### Example
At the in-game prompt you can create a temple by looking at a block and typing:
```javascript
/js temple()
```
Alternatively you can create a new Drone object from a Player or Location object and call the temple() method.
```javascript
var d = new Drone(player);
d.temple();
```
![temple example](img/templeex1.png)
***/
function temple( side ) { function temple( side ) {
if ( !side ) { if ( !side ) {
side = 20; side = 20;