Fixed bug in rainbow (wasn't drawing) and switched to using Bukkit Scheduler API for dancefloor drone function.

This commit is contained in:
walterhiggins 2013-02-16 22:22:45 +00:00
parent eaea34e172
commit 3f2bc8c80b
2 changed files with 11 additions and 12 deletions

View file

@ -13,7 +13,7 @@ Drone.extend('dancefloor',function(width,length)
//
// create a separate Drone object to lay down disco tiles
//
var disco = new Drone(this.x,this.y, this.z, this.dir);
var disco = new Drone(this.x, this.y, this.z, this.dir, this.world);
//
// under-floor lighting
//
@ -23,15 +23,14 @@ Drone.extend('dancefloor',function(width,length)
// strobe gets called in a java thread - disco only lasts 30 seconds.
//
var discoTicks = 30;
var strobe = function()
{
while(discoTicks--)
{
disco.rand(floorTiles,width,1,length);
java.lang.Thread.sleep(1000);
}
var task = null;
var strobe = function() {
disco.rand(floorTiles,width,1,length);
if (!discoTicks--)
task.cancel();
};
var thread = new java.lang.Thread(strobe);
thread.start();
var now = 0;
var everySecond = 20;
task = server.scheduler.runTaskTimer(__plugin,strobe,now,everySecond);
return this;
});

View file

@ -24,8 +24,8 @@ Drone.extend('rainbow', function(radius){
this.chkpt('rainbow');
this.down(radius);
// copy blocks.rainbow and add air at end (to compensate for strokewidth)
var colors = blocks.rainbow.slice(0).push(blocks.air);
var colors = blocks.rainbow.slice(0);
colors.push(blocks.air);
for (var i = 0;i < colors.length; i++) {
var bm = this._getBlockIdAndMeta(colors[i]);
this.arc({