mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-26 07:52:50 -05:00
30 lines
690 B
JavaScript
30 lines
690 B
JavaScript
|
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,
|
||
|
'math_add': this.add
|
||
|
};
|
||
|
};
|
||
|
|
||
|
|
||
|
Scratch3OperatorsBlocks.prototype.number = function(args) {
|
||
|
return Number(args.NUM);
|
||
|
};
|
||
|
|
||
|
Scratch3OperatorsBlocks.prototype.add = function(args) {
|
||
|
return args.NUM1 + args.NUM2;
|
||
|
};
|
||
|
|
||
|
module.exports = Scratch3OperatorsBlocks;
|