New drone.extend() style invocation.
This commit is contained in:
parent
cdccd1fe2e
commit
b74b4c4f28
7 changed files with 37 additions and 31 deletions
|
@ -10,8 +10,7 @@ var Drone = require('../drone').Drone;
|
||||||
//
|
//
|
||||||
// /js drone.cottage();
|
// /js drone.cottage();
|
||||||
//
|
//
|
||||||
|
function cottage( ) {
|
||||||
Drone.extend('cottage',function ( ) {
|
|
||||||
this.chkpt('cottage')
|
this.chkpt('cottage')
|
||||||
.box0(48,7,2,6) // 4 walls
|
.box0(48,7,2,6) // 4 walls
|
||||||
.right(3)
|
.right(3)
|
||||||
|
@ -28,12 +27,12 @@ Drone.extend('cottage',function ( ) {
|
||||||
.right(4)
|
.right(4)
|
||||||
.sign(['Home','Sweet','Home'],68)
|
.sign(['Home','Sweet','Home'],68)
|
||||||
.move('cottage');
|
.move('cottage');
|
||||||
});
|
}
|
||||||
//
|
//
|
||||||
// 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.
|
||||||
//
|
//
|
||||||
Drone.extend('cottage_road', function( numberCottages ) {
|
function cottage_road( numberCottages ) {
|
||||||
if (typeof numberCottages == 'undefined'){
|
if (typeof numberCottages == 'undefined'){
|
||||||
numberCottages = 6;
|
numberCottages = 6;
|
||||||
}
|
}
|
||||||
|
@ -90,5 +89,7 @@ Drone.extend('cottage_road', function( numberCottages ) {
|
||||||
}
|
}
|
||||||
// return drone to where it was at start of function
|
// return drone to where it was at start of function
|
||||||
return this.move('cottage_road');
|
return this.move('cottage_road');
|
||||||
});
|
}
|
||||||
|
Drone.extend(cottage_road);
|
||||||
|
Drone.extend(cottage);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ var Drone = require('../drone').Drone;
|
||||||
//
|
//
|
||||||
// See it in action here => http://www.youtube.com/watch?v=UEooBt6NTFo
|
// 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")
|
if (typeof width == "undefined")
|
||||||
width = 5;
|
width = 5;
|
||||||
|
@ -35,4 +35,5 @@ Drone.extend('dancefloor',function(width,length)
|
||||||
var everySecond = 20;
|
var everySecond = 20;
|
||||||
task = server.scheduler.runTaskTimer(__plugin,strobe,now,everySecond);
|
task = server.scheduler.runTaskTimer(__plugin,strobe,now,everySecond);
|
||||||
return this;
|
return this;
|
||||||
});
|
}
|
||||||
|
Drone.extend(dancefloor);
|
||||||
|
|
|
@ -10,7 +10,7 @@ function canHang( material ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Drone.extend('hangtorch', function () {
|
function hangtorch() {
|
||||||
var torch = '50:' + Drone.PLAYER_TORCH_FACING[this.dir];
|
var torch = '50:' + Drone.PLAYER_TORCH_FACING[this.dir];
|
||||||
var moves = 0;
|
var moves = 0;
|
||||||
var block = this.world.getBlockAt(this.x, this.y, this.z);
|
var block = this.world.getBlockAt(this.x, this.y, this.z);
|
||||||
|
@ -28,4 +28,5 @@ Drone.extend('hangtorch', function () {
|
||||||
}
|
}
|
||||||
this.box(torch)
|
this.box(torch)
|
||||||
.fwd(moves);
|
.fwd(moves);
|
||||||
});
|
}
|
||||||
|
Drone.extend(hangtorch);
|
||||||
|
|
|
@ -96,12 +96,12 @@ function maze_draw(maze_string, d) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function maze(size_x, size_y) {
|
||||||
// User-facing code starts here
|
|
||||||
// Example: Try /js amazing(5,7)
|
|
||||||
Drone.extend('amazing', function(size_x, size_y) {
|
|
||||||
m = maze_make(size_x, size_y);
|
m = maze_make(size_x, size_y);
|
||||||
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);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
// User-facing code starts here
|
||||||
|
// Example: Try /js amazing(5,7)
|
||||||
|
Drone.extend(maze);
|
||||||
|
|
|
@ -18,7 +18,7 @@ Creates a Rainbow.
|
||||||
![rainbow example](img/rainbowex1.png)
|
![rainbow example](img/rainbowex1.png)
|
||||||
|
|
||||||
***/
|
***/
|
||||||
Drone.extend('rainbow', function(radius){
|
function rainbow( radius ) {
|
||||||
var i,
|
var i,
|
||||||
colors,
|
colors,
|
||||||
bm;
|
bm;
|
||||||
|
@ -44,4 +44,5 @@ Drone.extend('rainbow', function(radius){
|
||||||
orientation: 'vertical'}).right().up();
|
orientation: 'vertical'}).right().up();
|
||||||
}
|
}
|
||||||
return this.move('rainbow');
|
return this.move('rainbow');
|
||||||
});
|
}
|
||||||
|
Drone.extend(rainbow);
|
||||||
|
|
|
@ -30,17 +30,18 @@ To construct a spiral staircase 5 floors high made of oak...
|
||||||
spiral_stairs('oak', 5);
|
spiral_stairs('oak', 5);
|
||||||
|
|
||||||
***/
|
***/
|
||||||
Drone.extend("spiral_stairs",function(stairBlock, flights){
|
function spiral_stairs(stairBlock, flights){
|
||||||
this.chkpt('spiral_stairs');
|
this.chkpt('spiral_stairs');
|
||||||
|
|
||||||
for (var i = 0; i < flights; i++){
|
for (var i = 0; i < flights; i++){
|
||||||
this
|
this
|
||||||
.box(blocks.stairs[stairBlock] + ':' + Drone.PLAYER_STAIRS_FACING[this.dir])
|
.box(blocks.stairs[stairBlock] + ':' + Drone.PLAYER_STAIRS_FACING[this.dir])
|
||||||
.up().fwd()
|
.up().fwd()
|
||||||
.box(blocks.stairs[stairBlock] + ':' + Drone.PLAYER_STAIRS_FACING[this.dir])
|
.box(blocks.stairs[stairBlock] + ':' + Drone.PLAYER_STAIRS_FACING[this.dir])
|
||||||
.up().fwd()
|
.up().fwd()
|
||||||
.box(blocks.slab[stairBlock])
|
.box(blocks.slab[stairBlock])
|
||||||
.turn().fwd();
|
.turn().fwd();
|
||||||
}
|
}
|
||||||
return this.move('spiral_stairs');
|
return this.move('spiral_stairs');
|
||||||
});
|
}
|
||||||
|
Drone.extend(spiral_stairs);
|
||||||
|
|
|
@ -2,7 +2,7 @@ var Drone = require('../drone').Drone;
|
||||||
//
|
//
|
||||||
// constructs a mayan temple
|
// constructs a mayan temple
|
||||||
//
|
//
|
||||||
Drone.extend('temple', function(side) {
|
function temple( side ) {
|
||||||
if ( !side ) {
|
if ( !side ) {
|
||||||
side = 20;
|
side = 20;
|
||||||
}
|
}
|
||||||
|
@ -27,4 +27,5 @@ Drone.extend('temple', function(side) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.move('temple');
|
this.move('temple');
|
||||||
});
|
}
|
||||||
|
Drone.extend(temple);
|
||||||
|
|
Reference in a new issue