Skip to content

Commit 06ebe8e

Browse files
committed
Change from Advance to Jump
1 parent 7ebcb00 commit 06ebe8e

File tree

4 files changed

+18
-30
lines changed

4 files changed

+18
-30
lines changed
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
*/
1717

1818
/**
19-
* @fileoverview This is a block that allows your code to use a parameter
20-
* that is passed to a method.
19+
* @fileoverview This is a block that allows your code to jump to a specific step.
2120
* @author [email protected] (Alan Smith)
2221
*/
2322
import * as Blockly from 'blockly';
@@ -27,42 +26,42 @@ import {ExtendedPythonGenerator} from '../editor/extended_python_generator';
2726
import {createFieldNonEditableText} from '../fields/FieldNonEditableText';
2827
import {MRC_STYLE_VARIABLES} from '../themes/styles';
2928

30-
export const BLOCK_NAME = 'mrc_advance_to_step';
29+
export const BLOCK_NAME = 'mrc_jump_to_step';
3130

3231
const FIELD_STEP_NAME = 'STEP_NAME';
3332

34-
type AdvanceToStepBlock = Blockly.Block & Blockly.BlockSvg & AdvanceToStepMixin;
33+
type JumpToStepBlock = Blockly.Block & Blockly.BlockSvg & JumpToStepMixin;
3534

36-
interface AdvanceToStepMixin extends AdvanceToStepMixinType {
35+
interface JumpToStepMixin extends JumpToStepMixinType {
3736
}
3837

39-
type AdvanceToStepMixinType = typeof ADVANCE_TO_STEP_BLOCK;
38+
type JumpToStepMixinType = typeof JUMP_TO_STEP_BLOCK;
4039

41-
const ADVANCE_TO_STEP_BLOCK = {
40+
const JUMP_TO_STEP_BLOCK = {
4241
/**
4342
* Block initialization.
4443
*/
45-
init: function(this: AdvanceToStepBlock): void {
44+
init: function(this: JumpToStepBlock): void {
4645
this.appendDummyInput()
47-
.appendField('Advance to step')
46+
.appendField('Jump to')
4847
.appendField(createFieldNonEditableText(''), FIELD_STEP_NAME);
4948
this.setPreviousStatement(true, null);
5049
this.setInputsInline(true);
5150
this.setStyle(MRC_STYLE_VARIABLES);
52-
this.setTooltip('Advance to the specified step when the condition is true.');
51+
this.setTooltip('Jump to the specified step.');
5352
},
5453
};
5554

5655
export const setup = function() {
57-
Blockly.Blocks[BLOCK_NAME] = ADVANCE_TO_STEP_BLOCK;
56+
Blockly.Blocks[BLOCK_NAME] = JUMP_TO_STEP_BLOCK;
5857
};
5958

6059
export const pythonFromBlock = function(
61-
block: AdvanceToStepBlock,
60+
block: JumpToStepBlock,
6261
_generator: ExtendedPythonGenerator,
6362
) {
6463
// TODO (Alan) : Specify the type here as well
65-
const code = '# TODO: Advance to step ' + block.getFieldValue(FIELD_STEP_NAME) + '\n';
64+
const code = '# TODO: Jump to step ' + block.getFieldValue(FIELD_STEP_NAME) + '\n';
6665

6766
return [code, Order.ATOMIC];
6867
};

src/blocks/mrc_steps.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,6 @@ const STEPS = {
4343
this.mrcStepNames = ["0"];
4444
this.appendDummyInput()
4545
.appendField(Blockly.Msg.STEPS);
46-
/*
47-
this.appendValueInput('CONDITION_0')
48-
.appendField(createStepFieldFlydown('shoot', true))
49-
.setCheck('Boolean')
50-
.appendField('Repeat Until');
51-
this.appendStatementInput('STEP_0');
52-
53-
this.appendValueInput('CONDITION_1')
54-
.appendField(createStepFieldFlydown('move', true))
55-
.setCheck('Boolean')
56-
.appendField('Repeat Until');
57-
this.appendStatementInput('STEP_1');
58-
*/
5946
this.setInputsInline(false);
6047
this.setStyle(MRC_STYLE_STEPS);
6148
this.setMutator(stepContainer.getMutatorIcon(this));

src/blocks/setup_custom_blocks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as Port from './mrc_port';
2020
import * as SetPythonVariable from './mrc_set_python_variable';
2121
import * as Steps from './mrc_steps';
2222
import * as StepContainer from './mrc_step_container';
23-
import * as AdvanceToStep from './mrc_advance_to_step';
23+
import * as JumpToStep from './mrc_jump_to_step';
2424

2525
const customBlocks = [
2626
CallPythonFunction,
@@ -44,7 +44,7 @@ const customBlocks = [
4444
SetPythonVariable,
4545
Steps,
4646
StepContainer,
47-
AdvanceToStep
47+
JumpToStep
4848
];
4949

5050
export const setup = function(forBlock: any) {

src/fields/field_flydown.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* https://github.com/mit-cml/blockly-plugins/blob/main/block-lexical-variables/src/fields/field_flydown.js
2424
*/
2525
import * as Blockly from 'blockly';
26+
import {BLOCK_NAME as JUMP_TO_STEP} from '../blocks/mrc_jump_to_step';
27+
import {BLOCK_NAME as GET_PARAMETER} from '../blocks/mrc_get_parameter';
2628

2729
enum FlydownLocation {
2830
DISPLAY_BELOW = 'displayBelow',
@@ -376,7 +378,7 @@ export function createParameterBlock(paramName: string): Blockly.utils.toolbox.F
376378
contents: [
377379
{
378380
kind: 'block',
379-
type: 'mrc_get_parameter',
381+
type: GET_PARAMETER,
380382
fields: {
381383
PARAMETER_NAME: paramName,
382384
},
@@ -390,7 +392,7 @@ export function createAdvanceToBlock(stepName: string): Blockly.utils.toolbox.Fl
390392
contents: [
391393
{
392394
kind: 'block',
393-
type: 'mrc_advance_to_step',
395+
type: JUMP_TO_STEP,
394396
fields: {
395397
STEP_NAME: stepName,
396398
},

0 commit comments

Comments
 (0)