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/contrib/streamer.js

20 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
*/
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;
});