Skip to content

Commit 5446cde

Browse files
authored
Merge pull request #107 from smalruby/issue/99
作ったブロックの命令ブロックをRubyに変換できる closes #99
2 parents 9a1e20e + eb2463d commit 5446cde

File tree

8 files changed

+119
-737
lines changed

8 files changed

+119
-737
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
node_modules/*
22
build/*
33
dist/*
4-
5-
src/lib/ruby-generator/generated.js

src/lib/ruby-generator/control.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function (Blockly) {
5050
};
5151

5252
Blockly.Ruby.control_start_as_clone = function (block) {
53-
Blockly.Ruby.targetEventBlock = block;
53+
block.isStatement = true;
5454
return `${Blockly.Ruby.spriteName()}.when(:start_as_a_clone) do\n`;
5555
};
5656

src/lib/ruby-generator/event.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@
55
*/
66
export default function (Blockly) {
77
Blockly.Ruby.event_whenflagclicked = function (block) {
8-
Blockly.Ruby.targetEventBlock = block;
8+
block.isStatement = true;
99
return `${Blockly.Ruby.spriteName()}.when(:flag_clicked) do\n`;
1010
};
1111

1212
Blockly.Ruby.event_whenthisspriteclicked = function (block) {
13-
Blockly.Ruby.targetEventBlock = block;
13+
block.isStatement = true;
1414
return `${Blockly.Ruby.spriteName()}.when(:click) do\n`;
1515
};
1616

1717
Blockly.Ruby.event_whenkeypressed = function (block) {
18-
Blockly.Ruby.targetEventBlock = block;
18+
block.isStatement = true;
1919
const key = Blockly.Ruby.quote_(block.getFieldValue('KEY_OPTION') || null);
2020
return `${Blockly.Ruby.spriteName()}.when(:key_pressed, ${key}) do\n`;
2121
};
2222

2323
Blockly.Ruby.event_whenbackdropswitchesto = function (block) {
24-
Blockly.Ruby.targetEventBlock = block;
24+
block.isStatement = true;
2525
const backdrop = Blockly.Ruby.quote_(block.getFieldValue('BACKDROP') || null);
2626
return `${Blockly.Ruby.spriteName()}.when(:backdrop_switches, ${backdrop}) do\n`;
2727
};
2828

2929
Blockly.Ruby.event_whengreaterthan = function (block) {
30-
Blockly.Ruby.targetEventBlock = block;
30+
block.isStatement = true;
3131
const lh = Blockly.Ruby.quote_(block.getFieldValue('WHENGREATERTHANMENU') || null);
3232
const rh = Blockly.Ruby.valueToCode(block, 'VALUE', Blockly.Ruby.ORDER_NONE) || '0';
3333
return `${Blockly.Ruby.spriteName()}.when(:greater_than, ${lh}, ${rh}) do\n`;
3434
};
3535

3636
Blockly.Ruby.event_whenbroadcastreceived = function (block) {
37-
Blockly.Ruby.targetEventBlock = block;
37+
block.isStatement = true;
3838
const message = Blockly.Ruby.broadcastMessageName(block.getFieldValue('BROADCAST_OPTION'));
3939
return `${Blockly.Ruby.spriteName()}.when(receive:, ${message}) do\n`;
4040
};
@@ -55,7 +55,7 @@ export default function (Blockly) {
5555
};
5656

5757
Blockly.Ruby.event_whenstageclicked = function (block) {
58-
Blockly.Ruby.targetEventBlock = block;
58+
block.isStatement = true;
5959
return `Stage.when(:stage_clicked) do\n`;
6060
};
6161

0 commit comments

Comments
 (0)