cloud-blocks
Version:
Cloud Blocks is a library for building scratch computing interfaces with Luxrobo MODI.
218 lines (208 loc) • 5.57 kB
JavaScript
/**
* @license
* Visual Blocks Editor
*
* Copyright 2016 Massachusetts Institute of Technology
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Control blocks for Scratch (Horizontal)
* @author ascii@media.mit.edu <Andrew Sliwinski>
*/
'use strict';
goog.provide('Blockly.Blocks.control');
goog.require('Blockly.Blocks');
goog.require('Blockly.Colours');
Blockly.Blocks['control_repeat'] = {
/**
* Block for repeat n times (external number).
* https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#so57n9
* @this Blockly.Block
*/
init: function () {
this.jsonInit({
id: 'control_repeat',
message0: '%1 %2 %3',
args0: [
{
type: 'input_statement',
name: 'SUBSTACK'
},
{
type: 'field_image',
src:
Blockly.mainWorkspace.options.pathToMedia +
'icons/control_repeat.svg',
width: 40,
height: 40,
alt: '*',
flip_rtl: true
},
{
type: 'input_value',
name: 'TIMES',
check: 'Number'
}
],
inputsInline: true,
previousStatement: null,
nextStatement: null,
category: Blockly.Categories.control,
colour: Blockly.Colours.control.primary,
colourSecondary: Blockly.Colours.control.secondary,
colourTertiary: Blockly.Colours.control.tertiary
});
}
};
Blockly.Blocks['control_forever'] = {
/**
* Block for repeat n times (external number).
* https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#5eke39
* @this Blockly.Block
*/
init: function () {
this.jsonInit({
id: 'control_forever',
message0: '%1 %2',
args0: [
{
type: 'input_statement',
name: 'SUBSTACK'
},
{
type: 'field_image',
src:
Blockly.mainWorkspace.options.pathToMedia +
'icons/control_forever.svg',
width: 40,
height: 40,
alt: '*',
flip_rtl: true
}
],
inputsInline: true,
previousStatement: null,
category: Blockly.Categories.control,
colour: Blockly.Colours.control.primary,
colourSecondary: Blockly.Colours.control.secondary,
colourTertiary: Blockly.Colours.control.tertiary
});
}
};
Blockly.Blocks['control_repeat'] = {
/**
* Block for repeat n times (external number).
* https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#so57n9
* @this Blockly.Block
*/
init: function () {
this.jsonInit({
id: 'control_repeat',
message0: '%1 %2 %3',
args0: [
{
type: 'input_statement',
name: 'SUBSTACK'
},
{
type: 'field_image',
src:
Blockly.mainWorkspace.options.pathToMedia +
'icons/control_repeat.svg',
width: 40,
height: 40,
alt: '*',
flip_rtl: true
},
{
type: 'input_value',
name: 'TIMES',
check: 'Number'
}
],
inputsInline: true,
previousStatement: null,
nextStatement: null,
category: Blockly.Categories.control,
colour: Blockly.Colours.control.primary,
colourSecondary: Blockly.Colours.control.secondary,
colourTertiary: Blockly.Colours.control.tertiary
});
}
};
Blockly.Blocks['control_stop'] = {
/**
* Block for stop all scripts.
* @this Blockly.Block
*/
init: function () {
this.jsonInit({
id: 'control_stop',
message0: '%1',
args0: [
{
type: 'field_image',
src:
Blockly.mainWorkspace.options.pathToMedia +
'icons/control_stop.svg',
width: 40,
height: 40,
alt: 'Stop'
}
],
inputsInline: true,
previousStatement: null,
category: Blockly.Categories.control,
colour: Blockly.Colours.control.primary,
colourSecondary: Blockly.Colours.control.secondary,
colourTertiary: Blockly.Colours.control.tertiary
});
}
};
Blockly.Blocks['control_wait'] = {
/**
* Block to wait (pause) stack.
* @this Blockly.Block
*/
init: function () {
this.jsonInit({
id: 'control_wait',
message0: '%1 %2',
args0: [
{
type: 'field_image',
src:
Blockly.mainWorkspace.options.pathToMedia +
'icons/control_wait.svg',
width: 40,
height: 40,
alt: 'Wait'
},
{
type: 'input_value',
name: 'DURATION',
check: 'Number'
}
],
inputsInline: true,
previousStatement: null,
nextStatement: null,
category: Blockly.Categories.control,
colour: Blockly.Colours.control.primary,
colourSecondary: Blockly.Colours.control.secondary,
colourTertiary: Blockly.Colours.control.tertiary
});
}
};