Skip to content

Commit 7e61ff3

Browse files
committed
update blocks
1 parent d647846 commit 7e61ff3

File tree

4 files changed

+80
-5
lines changed

4 files changed

+80
-5
lines changed

website/core/block_definitions.js

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24993,7 +24993,43 @@ Blockly.Blocks['getTime'] = {
2499324993
}
2499424994
};
2499524995

24996+
Blockly.Blocks['addTime'] = {
24997+
init: function() {
24998+
this.appendValueInput("value")
24999+
.setCheck("Number")
25000+
.appendField("add");
25001+
this.appendDummyInput()
25002+
.appendField(new Blockly.FieldDropdown([["seconds","PuppetBlocks.Time.SECOND"],
25003+
["minutes","PuppetBlocks.Time.MINUTE"],
25004+
["hours","PuppetBlocks.Time.HOUR"],
25005+
["days","PuppetBlocks.Time.DAY"],
25006+
["months","PuppetBlocks.Time.MONTH"],
25007+
["years","PuppetBlocks.Time.YEAR"]]), "unit");
25008+
this.appendValueInput("source_time")
25009+
.setCheck("PuppetBlocksTime")
25010+
.appendField("to");
25011+
this.setInputsInline(true);
25012+
this.setOutput(true, "PuppetBlocksTime");
25013+
this.setColour(110);
25014+
this.setTooltip("show text on screen");
25015+
this.setHelpUrl("#");
25016+
}
25017+
};
2499625018

24997-
24998-
24999-
25019+
Blockly.Blocks['getTimeUnit'] = {
25020+
init: function() {
25021+
this.appendDummyInput()
25022+
.appendField("get current")
25023+
.appendField(new Blockly.FieldDropdown([["seconds","PuppetBlocks.Time.SECOND"],
25024+
["minutes","PuppetBlocks.Time.MINUTE"],
25025+
["hours","PuppetBlocks.Time.HOUR"],
25026+
["days","PuppetBlocks.Time.DAY"],
25027+
["months","PuppetBlocks.Time.MONTH"],
25028+
["years","PuppetBlocks.Time.YEAR"]]), "unit");
25029+
this.setInputsInline(true);
25030+
this.setOutput(true, "PuppetBlocksTime");
25031+
this.setColour(110);
25032+
this.setTooltip("get current time");
25033+
this.setHelpUrl("#");
25034+
}
25035+
};

website/core/generator_stubs.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6718,4 +6718,19 @@ Blockly.Python['getTime'] = function(block) {
67186718
return [code, Blockly.Python.ORDER_NONE];
67196719
};
67206720

6721+
Blockly.Python['addTime'] = function(block) {
6722+
Blockly.Python.definitions_['import_puppet_block'] = 'import PuppetBlocks';
6723+
var value_value = Blockly.Python.valueToCode(block, 'value', Blockly.Python.ORDER_ATOMIC);
6724+
var dropdown_unit = block.getFieldValue('unit');
6725+
var value_source_time = Blockly.Python.valueToCode(block, 'source_time', Blockly.Python.ORDER_ATOMIC);
6726+
var code = 'PuppetBlocks.Time.getTime(' + value_source_time + ', ' + value_value + ', ' + dropdown_unit + ')';
6727+
return [code, Blockly.Python.ORDER_NONE];
6728+
};
6729+
6730+
Blockly.Python['getTimeUnit'] = function(block) {
6731+
Blockly.Python.definitions_['import_puppet_block'] = 'import PuppetBlocks';
6732+
var dropdown_unit = block.getFieldValue('unit');
6733+
var code = 'PuppetBlocks.Time.getTimeUnit(' + dropdown_unit + ')';
6734+
return [code, Blockly.Python.ORDER_NONE];
6735+
};
67216736

website/index_offline.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ <h2><span id="modalTitle"></span></h2>
12121212
<block type="sleepLibrary">
12131213
<value name="length">
12141214
<shadow type="math_number">
1215-
<field name="NUM"></field>
1215+
<field name="NUM">5</field>
12161216
</shadow>
12171217
</value>
12181218
</block>
@@ -1223,6 +1223,18 @@ <h2><span id="modalTitle"></span></h2>
12231223
</value>
12241224
</block>
12251225
<block type="getTime"></block>
1226+
<block type="addTime">
1227+
<value name="value">
1228+
<shadow type="math_number">
1229+
<field name="NUM">5</field>
1230+
</shadow>
1231+
</value>
1232+
<value name="source_time">
1233+
<shadow type="getTime">
1234+
</shadow>
1235+
</value>
1236+
</block>
1237+
<block type="getTimeUnit"></block>
12261238
</category>
12271239

12281240
</document>

website/toolbox/esp32.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@
392392
<block type="sleepLibrary">
393393
<value name="length">
394394
<shadow type="math_number">
395-
<field name="NUM"></field>
395+
<field name="NUM">5</field>
396396
</shadow>
397397
</value>
398398
</block>
@@ -403,6 +403,18 @@
403403
</value>
404404
</block>
405405
<block type="getTime"></block>
406+
<block type="addTime">
407+
<value name="value">
408+
<shadow type="math_number">
409+
<field name="NUM">5</field>
410+
</shadow>
411+
</value>
412+
<value name="source_time">
413+
<shadow type="getTime">
414+
</shadow>
415+
</value>
416+
</block>
417+
<block type="getTimeUnit"></block>
406418
</category>
407419

408420
</document>

0 commit comments

Comments
 (0)