Skip to content

Commit 9990bc3

Browse files
committed
update 1.2.1
Add new 3 blocks library NativeIO CCKey and CCDisk
1 parent 7ab5faf commit 9990bc3

25 files changed

+1405
-30
lines changed

blocks/CCDisk/block_design.json

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
{
2+
"disk_is_present": {
3+
"message0": "Is disk %1 present?",
4+
"args0": [
5+
{
6+
"type": "field_dropdown",
7+
"name": "SIDE",
8+
"options": [
9+
["Top", "top"],
10+
["Bottom", "bottom"],
11+
["Left", "left"],
12+
["Right", "right"],
13+
["Front", "front"],
14+
["Back", "back"]
15+
]
16+
}
17+
],
18+
"output": "Boolean",
19+
"colour": 160,
20+
"tooltip": "Check if any item is present in the disk drive"
21+
},
22+
"disk_get_label": {
23+
"message0": "get label disk %1",
24+
"args0": [
25+
{
26+
"type": "field_dropdown",
27+
"name": "SIDE",
28+
"options": [
29+
["Top", "top"],
30+
["Bottom", "bottom"],
31+
["Left", "left"],
32+
["Right", "right"],
33+
["Front", "front"],
34+
["Back", "back"]
35+
]
36+
}
37+
],
38+
"output": "String",
39+
"colour": 160,
40+
"tooltip": "Get the label of the disk in the drive"
41+
},
42+
"disk_set_label": {
43+
"message0": "set label disk %1 to %2",
44+
"args0": [
45+
{
46+
"type": "field_dropdown",
47+
"name": "SIDE",
48+
"options": [
49+
["Top", "top"],
50+
["Bottom", "bottom"],
51+
["Left", "left"],
52+
["Right", "right"],
53+
["Front", "front"],
54+
["Back", "back"]
55+
]
56+
},
57+
{
58+
"type": "input_value",
59+
"name": "LABEL",
60+
"check": "String"
61+
}
62+
],
63+
"previousStatement": null,
64+
"nextStatement": null,
65+
"colour": 160,
66+
"tooltip": "Set the label of the disk in the drive"
67+
},
68+
"disk_has_data": {
69+
"message0": "Is disk %1 have data?",
70+
"args0": [
71+
{
72+
"type": "field_dropdown",
73+
"name": "SIDE",
74+
"options": [
75+
["Top", "top"],
76+
["Bottom", "bottom"],
77+
["Left", "left"],
78+
["Right", "right"],
79+
["Front", "front"],
80+
["Back", "back"]
81+
]
82+
}
83+
],
84+
"output": "Boolean",
85+
"colour": 160,
86+
"tooltip": "Check if the disk has data"
87+
},
88+
"disk_get_mount_path": {
89+
"message0": "get mount path of disk %1",
90+
"args0": [
91+
{
92+
"type": "field_dropdown",
93+
"name": "SIDE",
94+
"options": [
95+
["Top", "top"],
96+
["Bottom", "bottom"],
97+
["Left", "left"],
98+
["Right", "right"],
99+
["Front", "front"],
100+
["Back", "back"]
101+
]
102+
}
103+
],
104+
"output": "String",
105+
"colour": 160,
106+
"tooltip": "Get the mount path of the disk"
107+
},
108+
"disk_has_audio": {
109+
"message0": "Is disk %1 have audio?",
110+
"args0": [
111+
{
112+
"type": "field_dropdown",
113+
"name": "SIDE",
114+
"options": [
115+
["Top", "top"],
116+
["Bottom", "bottom"],
117+
["Left", "left"],
118+
["Right", "right"],
119+
["Front", "front"],
120+
["Back", "back"]
121+
]
122+
}
123+
],
124+
"output": "Boolean",
125+
"colour": 160,
126+
"tooltip": "Check if the disk has audio"
127+
},
128+
"disk_get_audio_title": {
129+
"message0": "get audio title of disk %1",
130+
"args0": [
131+
{
132+
"type": "field_dropdown",
133+
"name": "SIDE",
134+
"options": [
135+
["Top", "top"],
136+
["Bottom", "bottom"],
137+
["Left", "left"],
138+
["Right", "right"],
139+
["Front", "front"],
140+
["Back", "back"]
141+
]
142+
}
143+
],
144+
"output": ["String", "Boolean"],
145+
"colour": 160,
146+
"tooltip": "Get the title of the audio track"
147+
},
148+
"disk_play_audio": {
149+
"message0": "play audio disk %1",
150+
"args0": [
151+
{
152+
"type": "field_dropdown",
153+
"name": "SIDE",
154+
"options": [
155+
["Top", "top"],
156+
["Bottom", "bottom"],
157+
["Left", "left"],
158+
["Right", "right"],
159+
["Front", "front"],
160+
["Back", "back"]
161+
]
162+
}
163+
],
164+
"previousStatement": null,
165+
"nextStatement": null,
166+
"colour": 160,
167+
"tooltip": "Play the audio track on the disk"
168+
},
169+
"disk_stop_audio": {
170+
"message0": "stop audio on %1",
171+
"args0": [
172+
{
173+
"type": "field_dropdown",
174+
"name": "SIDE",
175+
"options": [
176+
["Top", "top"],
177+
["Bottom", "bottom"],
178+
["Left", "left"],
179+
["Right", "right"],
180+
["Front", "front"],
181+
["Back", "back"]
182+
]
183+
}
184+
],
185+
"previousStatement": null,
186+
"nextStatement": null,
187+
"colour": 160,
188+
"tooltip": "Stop the audio track on the disk"
189+
},
190+
"disk_eject": {
191+
"message0": "eject disk %1",
192+
"args0": [
193+
{
194+
"type": "field_dropdown",
195+
"name": "SIDE",
196+
"options": [
197+
["Top", "top"],
198+
["Bottom", "bottom"],
199+
["Left", "left"],
200+
["Right", "right"],
201+
["Front", "front"],
202+
["Back", "back"]
203+
]
204+
}
205+
],
206+
"previousStatement": null,
207+
"nextStatement": null,
208+
"colour": 160,
209+
"tooltip": "Eject the disk from the drive",
210+
"helpUrl": ""
211+
},
212+
"disk_get_id": {
213+
"message0": "get ID of disk %1",
214+
"args0": [
215+
{
216+
"type": "field_dropdown",
217+
"name": "SIDE",
218+
"options": [
219+
["Top", "top"],
220+
["Bottom", "bottom"],
221+
["Left", "left"],
222+
["Right", "right"],
223+
["Front", "front"],
224+
["Back", "back"]
225+
]
226+
}
227+
],
228+
"output": "String",
229+
"colour": 160,
230+
"tooltip": "Get the unique ID of the disk"
231+
}
232+
}

blocks/CCDisk/generator.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// this file not for generator only
2+
3+
const { luaGenerator } = require('blockly/lua');
4+
5+
// Check if luaGenerator.forBlock is defined and initialize if necessary
6+
if (!luaGenerator.forBlock) {
7+
luaGenerator.forBlock = {};
8+
}
9+
10+
luaGenerator.forBlock['disk_is_present'] = function(block, generator) {
11+
var side = block.getFieldValue('SIDE');
12+
13+
return [`disk.isPresent("${side}")`, luaGenerator.ORDER_NONE];
14+
};
15+
16+
luaGenerator.forBlock['disk_get_label'] = function(block, generator) {
17+
var side = block.getFieldValue('SIDE');
18+
19+
return [`disk.getLabel("${side}")`, luaGenerator.ORDER_NONE];
20+
};
21+
22+
luaGenerator.forBlock['disk_set_label'] = function(block, generator) {
23+
var side = block.getFieldValue('SIDE');
24+
var label = generator.valueToCode(block, 'LABEL', generator.ORDER_ATOMIC);
25+
26+
return `disk.setLabel("${side}", ${label})\n`;
27+
};
28+
29+
luaGenerator.forBlock['disk_has_data'] = function(block, generator) {
30+
var side = block.getFieldValue('SIDE');
31+
32+
return [`disk.hasData("${side}")`, luaGenerator.ORDER_NONE];
33+
};
34+
35+
luaGenerator.forBlock['disk_get_mount_path'] = function(block, generator) {
36+
var side = block.getFieldValue('SIDE');
37+
38+
return [`disk.getMountPath("${side}")`, luaGenerator.ORDER_NONE];
39+
};
40+
41+
luaGenerator.forBlock['disk_has_audio'] = function(block, generator) {
42+
var side = block.getFieldValue('SIDE');
43+
44+
return [`disk.hasAudio("${side}")`, luaGenerator.ORDER_NONE];
45+
};
46+
47+
luaGenerator.forBlock['disk_get_audio_title'] = function(block, generator) {
48+
var side = block.getFieldValue('SIDE');
49+
50+
return [`disk.getAudioTitle("${side}")`, luaGenerator.ORDER_NONE];
51+
};
52+
53+
luaGenerator.forBlock['disk_play_audio'] = function(block, generator) {
54+
var side = block.getFieldValue('SIDE');
55+
56+
return `disk.playAudio("${side}")\n`;
57+
};
58+
59+
luaGenerator.forBlock['disk_stop_audio'] = function(block, generator) {
60+
var side = block.getFieldValue('SIDE');
61+
62+
return `disk.stopAudio("${side}")\n`;
63+
};
64+
65+
luaGenerator.forBlock['disk_eject'] = function(block, generator) {
66+
var side = block.getFieldValue('SIDE');
67+
68+
return `disk.eject("${side}")\n`;
69+
};
70+
71+
luaGenerator.forBlock['disk_get_id'] = function(block, generator) {
72+
var side = block.getFieldValue('SIDE');
73+
74+
return [`disk.getID("${side}")`, luaGenerator.ORDER_NONE];
75+
};

blocks/CCDisk/index.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "CC: Disk",
3+
"author": "DPSoftware Foundation",
4+
"description": "Blocks for performing operations on disk drives in ccIDE",
5+
"version": "1.0.0",
6+
"category": "",
7+
"keyword": "disk, operations, ccIDE",
8+
"license": "GPL-3.0-or-later",
9+
"peripherals": true,
10+
"library": true,
11+
"require_network": false,
12+
"dependencies": {},
13+
"design_for_computer": {
14+
"basic": true,
15+
"adv": true,
16+
"command": true,
17+
"pocket": false,
18+
"advpocket": false,
19+
"turtle": true,
20+
"advturtle": true
21+
}
22+
}

blocks/CCDisk/toolbox.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<xml id="toolbox" style="display: none;">
2+
<category name="Disk" colour="160">
3+
<block type="disk_is_present"></block>
4+
<block type="disk_get_label"></block>
5+
<block type="disk_set_label"></block>
6+
<block type="disk_has_data"></block>
7+
<block type="disk_get_mount_path"></block>
8+
<block type="disk_has_audio"></block>
9+
<block type="disk_get_audio_title"></block>
10+
<block type="disk_play_audio"></block>
11+
<block type="disk_stop_audio"></block>
12+
<block type="disk_eject"></block>
13+
<block type="disk_get_id"></block>
14+
</category>
15+
</xml>

0 commit comments

Comments
 (0)