mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-25 21:50:59 -04:00
Implement stub for number and add blocks
This commit is contained in:
parent
a987d9d9cc
commit
b0441e2ef5
2 changed files with 30 additions and 0 deletions
src
29
src/blocks/scratch3_operators.js
Normal file
29
src/blocks/scratch3_operators.js
Normal file
|
@ -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.<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;
|
|
@ -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')
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue