diff --git a/src/blocks/scratch3_operators.js b/src/blocks/scratch3_operators.js new file mode 100644 index 00000000..319f3f36 --- /dev/null +++ b/src/blocks/scratch3_operators.js @@ -0,0 +1,29 @@ +function Scratch3OperatorsBlocks(runtime) { + /** + * The runtime instantiating this block package. + * @type {Runtime} + */ + this.runtime = runtime; +} + +/** + * Retrieve the block primitives implemented by this package. + * @return {Object.} 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; diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 5b4fab48..07debdd6 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -6,6 +6,7 @@ var util = require('util'); var defaultBlockPackages = { 'scratch3_control': require('../blocks/scratch3_control'), 'scratch3_event': require('../blocks/scratch3_event'), + 'scratch3_operators': require('../blocks/scratch3_operators'), 'wedo2': require('../blocks/wedo2') };