Make putsign use drone queue and add informative messages for senders.

This commit is contained in:
walterhiggins 2014-03-10 23:18:33 +00:00
parent e40786d727
commit 30d1d89e91

View file

@ -658,11 +658,15 @@ var putBlock = function( x, y, z, blockId, metadata, world ) {
} }
}; };
var putSign = function( texts, x, y, z, blockId, meta, world ) { var putSign = function( texts, x, y, z, blockId, meta, world, immediate ) {
var i, var i,
block, block,
state; state;
if ( !immediate ) {
Drone.queue.push(function(){ putSign(texts, x, y, z, blockId, meta, world, true); });
return;
}
if ( blockId != 63 && blockId != 68 ) { if ( blockId != 63 && blockId != 68 ) {
throw new Error( 'Invalid Parameter: blockId must be 63 or 68' ); throw new Error( 'Invalid Parameter: blockId must be 63 or 68' );
} }
@ -738,6 +742,7 @@ var Drone = function( x, y, z, dir, world ) {
this.chkpt( 'start' ); this.chkpt( 'start' );
this.record = true; this.record = true;
this.history = []; this.history = [];
this.player = player;
return this; return this;
}; };
@ -787,7 +792,15 @@ Drone.extend = function( name, func ) {
global[name] = function( ) { global[name] = function( ) {
var result = new Drone( self ); var result = new Drone( self );
var len = Drone.queue.length;
result[name].apply( result, arguments ); result[name].apply( result, arguments );
var newLen = Drone.queue.length;
if ( len > (3 * Drone.opsPerSec) || (newLen - len) > (3 * Drone.opsPerSec)) {
if ( result.player && !result.playerNotifiedPending ) {
result.player.sendMessage('Build queue will complete in ' + Math.ceil( newLen / Drone.opsPerSec ) + ' seconds (approx.)');
result.playerNotifiedPending = true;
}
}
return result; return result;
}; };
}; };
@ -1522,8 +1535,13 @@ var _cylinder1 = function( block,radius,height,exactParams ) {
} }
return this.arc(arcParams ); return this.arc(arcParams );
}; };
var _paste = function( name ) var _paste = function( name, immediate )
{ {
if ( !immediate ) {
Drone.queue.push(function(){ _paste(name, true);});
return;
}
var ccContent = Drone.clipBoard[name]; var ccContent = Drone.clipBoard[name];
var srcBlocks = ccContent.blocks; var srcBlocks = ccContent.blocks;
var srcDir = ccContent.dir; // direction player was facing when copied. var srcDir = ccContent.dir; // direction player was facing when copied.