2016-05-02 12:20:27 -04:00
|
|
|
|
2016-05-02 14:07:40 -04:00
|
|
|
function WeDo2Blocks(runtime) {
|
|
|
|
/**
|
|
|
|
* The runtime instantiating this block package.
|
|
|
|
* @type {Runtime}
|
|
|
|
*/
|
|
|
|
this.runtime = runtime;
|
2016-05-02 12:20:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the block primitives implemented by this package.
|
|
|
|
* @return {Object.<string, Function>} Mapping of opcode to Function.
|
|
|
|
*/
|
|
|
|
WeDo2Blocks.prototype.getPrimitives = function() {
|
|
|
|
return {
|
2016-05-02 14:07:40 -04:00
|
|
|
'wedo_motorclockwise': this.motorClockwise,
|
|
|
|
'wedo_motorcounterclockwise': this.motorCounterClockwise,
|
|
|
|
'wedo_motorspeed': this.motorSpeed,
|
|
|
|
'wedo_setcolor': this.setColor,
|
|
|
|
'wedo_whendistanceclose': this.whenDistanceClose,
|
|
|
|
'wedo_whentilt': this.whenTilt
|
2016-05-02 12:20:27 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-05-02 14:07:40 -04:00
|
|
|
WeDo2Blocks.prototype.motorClockwise = function() {
|
|
|
|
console.log('Running: wedo_motorclockwise');
|
|
|
|
};
|
|
|
|
|
|
|
|
WeDo2Blocks.prototype.motorCounterClockwise = function() {
|
|
|
|
console.log('Running: wedo_motorcounterclockwise');
|
|
|
|
};
|
|
|
|
|
|
|
|
WeDo2Blocks.prototype.motorSpeed = function() {
|
|
|
|
console.log('Running: wedo_motorspeed');
|
|
|
|
};
|
|
|
|
|
|
|
|
WeDo2Blocks.prototype.setColor = function() {
|
|
|
|
console.log('Running: wedo_setcolor');
|
|
|
|
};
|
|
|
|
|
|
|
|
WeDo2Blocks.prototype.whenDistanceClose = function() {
|
|
|
|
console.log('Running: wedo_whendistanceclose');
|
|
|
|
};
|
|
|
|
|
|
|
|
WeDo2Blocks.prototype.whenTilt = function() {
|
|
|
|
console.log('Running: wedo_whentilt');
|
|
|
|
};
|
|
|
|
|
2016-05-02 12:20:27 -04:00
|
|
|
module.exports = WeDo2Blocks;
|