This repository has been archived on 2021-07-14. You can view files and clone it, but cannot push or open issues or pull requests.
scriptcraft/src/main/javascript/drone/streamer.js
2013-02-04 21:48:07 -06:00

22 lines
541 B
JavaScript

/**
* Creates a stream of blocks in a given direction until it hits something other than air
*
* Parameters:
* block - blockId
* dir - "up", "down", "left", "right", "fwd", "back
* maxIterations - (Optional) maximum number of cubes to generate, defaults to 1000
*/
load(__folder + "drone.js");
Drone.extend("streamer", function(block, dir, maxIterations) {
for(var i = 0; i < maxIterations||1000; ++i) {
this.box(block);
this[dir].call(this);
if(getBlock(this.x, this.y, this.z) !== "0:0") {
break;
}
}
return this;
});