2016-06-09 14:29:07 -04:00
|
|
|
function Scratch3OperatorsBlocks(runtime) {
|
|
|
|
/**
|
|
|
|
* The runtime instantiating this block package.
|
|
|
|
* @type {Runtime}
|
|
|
|
*/
|
|
|
|
this.runtime = runtime;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the block primitives implemented by this package.
|
|
|
|
* @return {Object.<string, Function>} Mapping of opcode to Function.
|
|
|
|
*/
|
|
|
|
Scratch3OperatorsBlocks.prototype.getPrimitives = function() {
|
|
|
|
return {
|
|
|
|
'math_number': this.number,
|
2016-06-10 10:36:05 -04:00
|
|
|
'text': this.text,
|
|
|
|
'math_add': this.add,
|
|
|
|
'logic_equals': this.equals
|
2016-06-09 14:29:07 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-06-10 10:36:05 -04:00
|
|
|
Scratch3OperatorsBlocks.prototype.number = function (args) {
|
2016-06-09 14:29:07 -04:00
|
|
|
return Number(args.NUM);
|
|
|
|
};
|
|
|
|
|
2016-06-10 10:36:05 -04:00
|
|
|
Scratch3OperatorsBlocks.prototype.text = function (args) {
|
|
|
|
return String(args.TEXT);
|
|
|
|
};
|
|
|
|
|
|
|
|
Scratch3OperatorsBlocks.prototype.add = function (args) {
|
2016-06-09 14:29:07 -04:00
|
|
|
return args.NUM1 + args.NUM2;
|
|
|
|
};
|
|
|
|
|
2016-06-10 10:36:05 -04:00
|
|
|
Scratch3OperatorsBlocks.prototype.equals = function (args) {
|
|
|
|
return args.VALUE1 == args.VALUE2;
|
|
|
|
};
|
|
|
|
|
2016-06-09 14:29:07 -04:00
|
|
|
module.exports = Scratch3OperatorsBlocks;
|