Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* (klein0r) Added new blocks: new line, random number, value between …
…min and max, if empty
- Loading branch information
1 parent
01ee3e8
commit a6db742
Showing
26 changed files
with
284 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
// --- Round Number to n decimal places ------------------------------- | ||
|
||
Blockly.Blocks['math_rndfixed'] = { | ||
init: function() { | ||
this.appendValueInput('x') | ||
.setCheck('Number') | ||
.appendField(Blockly.Translate('math_rndfixed_round')); | ||
this.appendDummyInput() | ||
.appendField(Blockly.Translate('math_rndfixed_to')) | ||
.appendField(new Blockly.FieldNumber(0, 1, 25), 'n') | ||
.appendField(Blockly.Translate('math_rndfixed_decplcs')); | ||
this.setInputsInline(true); | ||
this.setColour(Blockly.Msg['MATH_HUE']); | ||
this.setOutput(true, 'Number'); | ||
this.setTooltip(Blockly.Translate('math_rndfixed_tooltip')); | ||
} | ||
}; | ||
|
||
Blockly.JavaScript['math_rndfixed'] = function(block) { | ||
var x = Blockly.JavaScript.valueToCode(block, 'x', Blockly.JavaScript.ORDER_ATOMIC); | ||
var exp = Math.pow(10, block.getFieldValue('n')); | ||
return ['Math.round(' + x + ' * ' + exp + ') / ' + exp, Blockly.JavaScript.ORDER_ATOMIC]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
// --- Text new line -------------------------------------------------- | ||
|
||
Blockly.Blocks['text_newline'] = { | ||
// Checkbox. | ||
init: function() { | ||
this.appendDummyInput() | ||
.appendField(Blockly.Translate('text_newline')); | ||
|
||
this.appendDummyInput() | ||
.appendField(new Blockly.FieldDropdown([['\\n', '\\n'], ['\\r\\n', '\\r\\n'], ['\\r', '\\r']]), 'Type'); | ||
this.setInputsInline(true); | ||
this.setColour(Blockly.Msg['TEXTS_HUE']); | ||
this.setOutput(true, 'String'); | ||
this.setTooltip(Blockly.Translate('text_newline_tooltip')); | ||
} | ||
}; | ||
|
||
Blockly.JavaScript['text_newline'] = function(block) { | ||
var dropdown_type = block.getFieldValue('Type'); | ||
return ['\'' + dropdown_type + '\'', Blockly.JavaScript.ORDER_ATOMIC]; | ||
}; |
Oops, something went wrong.