added "^" reporter (power of) in the Operators category

pull/89/head
jmoenig 2019-03-12 11:18:05 +01:00
rodzic 3686b71a72
commit 94bf8e0402
3 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -14,11 +14,12 @@
* new "play frequency" command in the Sound category
* blocks for changing and querying the "flat line ends" setting
* selectors for changing and querying "draggable" and "rotation style" settings
* added "neg" selector to monadic function reporter in "Operators" category
* added "^" reporter (power of) in the Operators category
* special context-aware drop-downs for custom blocks
* new "stick to" submenu in the sprite context menu where applicable
* multi-line and monospaced "code" input slots for custom blocks
* new "string" library, thanks, Brian
* added "neg" selector to monadic function reporter in "Operators" category
* new "text costumes" library for generating costumes from letters or words of text
* enhanced support for embedding Snap in other website, thanks, Bernat!
* export sounds

Wyświetl plik

@ -948,6 +948,11 @@ SpriteMorph.prototype.initBlocks = function () {
spec: '%fun of %n',
defaults: [null, 10]
},
reportPower: {
type: 'reporter',
category: 'operators',
spec: '%n ^ %n'
},
reportModulus: {
type: 'reporter',
category: 'operators',
@ -2106,6 +2111,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('reportDifference'));
blocks.push(block('reportProduct'));
blocks.push(block('reportQuotient'));
blocks.push(block('reportPower'));
blocks.push('-');
blocks.push(block('reportModulus'));
blocks.push(block('reportRound'));
@ -2958,6 +2964,7 @@ SpriteMorph.prototype.reporterize = function (expressionString) {
'*': 'reportProduct',
'/': 'reportQuotient',
'%': 'reportModulus',
'^': 'reportPower',
'=': 'reportEquals',
'<': 'reportLessThan',
'>': 'reportGreaterThan',
@ -7351,6 +7358,7 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push(block('reportDifference'));
blocks.push(block('reportProduct'));
blocks.push(block('reportQuotient'));
blocks.push(block('reportPower'));
blocks.push('-');
blocks.push(block('reportModulus'));
blocks.push(block('reportRound'));

Wyświetl plik

@ -2564,6 +2564,10 @@ Process.prototype.reportQuotient = function (a, b) {
return +a / +b;
};
Process.prototype.reportPower = function (a, b) {
return Math.pow(+a, +b);
};
Process.prototype.reportModulus = function (a, b) {
var x = +a,
y = +b;