-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerators.ts
More file actions
71 lines (62 loc) · 3.08 KB
/
generators.ts
File metadata and controls
71 lines (62 loc) · 3.08 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Blockly.Python['import_bitbot'] = function(block) {
var code = 'from BitBotXL import *\n';
return code;
};
Blockly.Python['bitbot_init'] = function(block) {
var variable_robot = Blockly.Python.variableDB_.getName(block.getFieldValue('robot'), Blockly.Variables.NAME_TYPE);
// TODO: Assemble Python into code variable.
var code = variable_robot + ' = bitBotXL()\n';
return code;
};
Blockly.Python['bitbot_direction'] = function(block) {
var variable_robot = Blockly.Python.variableDB_.getName(block.getFieldValue('robot'), Blockly.Variables.NAME_TYPE);
var dropdown_directions = block.getFieldValue('directions');
var value_name = Blockly.Python.valueToCode(block, 'NAME', Blockly.Python.ORDER_ATOMIC);
// TODO: Assemble Python into code variable.
var code = variable_robot+ '.' +dropdown_directions+ '(' +value_name+ ')\n';
return code;
};
Blockly.Python['bitbotneovarnew'] = function(block) {
var variable_name = Blockly.Python.variableDB_.getName(block.getFieldValue('robot'), Blockly.Variables.NAME_TYPE);
var text_neonum = Blockly.Python.valueToCode(block, 'text', Blockly.Python.ORDER_ATOMIC)
|| 'True';
var text_colour = Blockly.Python.valueToCode(block, 'text1', Blockly.Python.ORDER_ATOMIC)
|| 'True';
// TODO: Assemble Python into code variable.
var code = variable_name+ '.leds[' +text_neonum+ '] = (' +text_colour+ ')\n';
return code;
};
Blockly.Python['bitbotneoshow'] = function(block) {
var variable_name = Blockly.Python.variableDB_.getName(block.getFieldValue('robot'), Blockly.Variables.NAME_TYPE);
// TODO: Assemble Python into code variable.
var code = variable_name+ 'leds.show()\n';
return code;
};
Blockly.Python['bitbotneoclear'] = function(block) {
var variable_name = Blockly.Python.variableDB_.getName(block.getFieldValue('robot'), Blockly.Variables.NAME_TYPE);
// TODO: Assemble Python into code variable.
var code = variable_name+ 'leds.clear()\n';
return code;
};
Blockly.Python['sliderinlinerobot'] = function(block) {
var text_text = block.getFieldValue('slider');
// TODO: Assemble Python into code variable.
var code = text_text;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_ATOMIC];
};
Blockly.Python['bitbot_stop'] = function(block) {
var variable_robot = Blockly.Python.variableDB_.getName(block.getFieldValue('robot'), Blockly.Variables.NAME_TYPE);
var value_stop = Blockly.Python.valueToCode(block, 'stop', Blockly.Python.ORDER_ATOMIC);
// TODO: Assemble Python into code variable.
var code = variable_robot+ '.stop(' + value_stop+ ')\n';
return code;
};
Blockly.Python['bitbot_sonar'] = function(block) {
var variable_robot = Blockly.Python.variableDB_.getName(block.getFieldValue('robot'), Blockly.Variables.NAME_TYPE);
var dropdown_measure = block.getFieldValue('measure');
// TODO: Assemble Python into code variable.
var code = variable_robot + '.sonar_' +dropdown_measure+ '()';
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_ATOMIC];
};