New drone.extend() style invocation.

This commit is contained in:
walterhiggins 2014-08-23 16:45:43 +01:00
parent cdccd1fe2e
commit b74b4c4f28
7 changed files with 37 additions and 31 deletions

View file

@ -10,8 +10,7 @@ var Drone = require('../drone').Drone;
//
// /js drone.cottage();
//
Drone.extend('cottage',function ( ) {
function cottage( ) {
this.chkpt('cottage')
.box0(48,7,2,6) // 4 walls
.right(3)
@ -28,12 +27,12 @@ Drone.extend('cottage',function ( ) {
.right(4)
.sign(['Home','Sweet','Home'],68)
.move('cottage');
});
}
//
// a more complex script that builds an tree-lined avenue with
// cottages on both sides.
//
Drone.extend('cottage_road', function( numberCottages ) {
function cottage_road( numberCottages ) {
if (typeof numberCottages == 'undefined'){
numberCottages = 6;
}
@ -90,5 +89,7 @@ Drone.extend('cottage_road', function( numberCottages ) {
}
// return drone to where it was at start of function
return this.move('cottage_road');
});
}
Drone.extend(cottage_road);
Drone.extend(cottage);

View file

@ -6,7 +6,7 @@ var Drone = require('../drone').Drone;
//
// See it in action here => http://www.youtube.com/watch?v=UEooBt6NTFo
//
Drone.extend('dancefloor',function(width,length)
function dancefloor(width,length)
{
if (typeof width == "undefined")
width = 5;
@ -35,4 +35,5 @@ Drone.extend('dancefloor',function(width,length)
var everySecond = 20;
task = server.scheduler.runTaskTimer(__plugin,strobe,now,everySecond);
return this;
});
}
Drone.extend(dancefloor);

View file

@ -10,7 +10,7 @@ function canHang( material ) {
return false;
}
}
Drone.extend('hangtorch', function () {
function hangtorch() {
var torch = '50:' + Drone.PLAYER_TORCH_FACING[this.dir];
var moves = 0;
var block = this.world.getBlockAt(this.x, this.y, this.z);
@ -28,4 +28,5 @@ Drone.extend('hangtorch', function () {
}
this.box(torch)
.fwd(moves);
});
}
Drone.extend(hangtorch);

View file

@ -96,12 +96,12 @@ function maze_draw(maze_string, d) {
}
}
}
// User-facing code starts here
// Example: Try /js amazing(5,7)
Drone.extend('amazing', function(size_x, size_y) {
function maze(size_x, size_y) {
m = maze_make(size_x, size_y);
if (m.x > 0 && m.y > 0) {
maze_draw(maze_display(m), this);
}
});
}
// User-facing code starts here
// Example: Try /js amazing(5,7)
Drone.extend(maze);

View file

@ -18,7 +18,7 @@ Creates a Rainbow.
![rainbow example](img/rainbowex1.png)
***/
Drone.extend('rainbow', function(radius){
function rainbow( radius ) {
var i,
colors,
bm;
@ -44,4 +44,5 @@ Drone.extend('rainbow', function(radius){
orientation: 'vertical'}).right().up();
}
return this.move('rainbow');
});
}
Drone.extend(rainbow);

View file

@ -30,7 +30,7 @@ To construct a spiral staircase 5 floors high made of oak...
spiral_stairs('oak', 5);
***/
Drone.extend("spiral_stairs",function(stairBlock, flights){
function spiral_stairs(stairBlock, flights){
this.chkpt('spiral_stairs');
for (var i = 0; i < flights; i++){
@ -43,4 +43,5 @@ Drone.extend("spiral_stairs",function(stairBlock, flights){
.turn().fwd();
}
return this.move('spiral_stairs');
});
}
Drone.extend(spiral_stairs);

View file

@ -2,7 +2,7 @@ var Drone = require('../drone').Drone;
//
// constructs a mayan temple
//
Drone.extend('temple', function(side) {
function temple( side ) {
if ( !side ) {
side = 20;
}
@ -27,4 +27,5 @@ Drone.extend('temple', function(side) {
}
this.move('temple');
});
}
Drone.extend(temple);