forked from sayamindu/scratch-extensions
-
Notifications
You must be signed in to change notification settings - Fork 2
/
power_extension.js
30 lines (24 loc) · 864 Bytes
/
power_extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Extension demonstrating a reporter block */
/* Sayamindu Dasgupta <[email protected]>, May 2014 */
new (function() {
var ext = this;
// Cleanup function when the extension is unloaded
ext._shutdown = function() {};
// Status reporting code
// Use this to report missing hardware, plugin or unsupported browser
ext._getStatus = function() {
return {status: 2, msg: 'Ready'};
};
ext.power = function(base, exponent) {
return Math.pow(base, exponent);
};
// Block and block menu descriptions
var descriptor = {
blocks: [
// Block type, block name, function name, param1 default value, param2 default value
['r', '%n ^ %n', 'power', 2, 3],
]
};
// Register the extension
ScratchExtensions.register('Sample extension', descriptor, ext);
})();