Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const json = jsonForMenuBlock('TO', spriteMenu, motionColors, [
[random, '_random_'],
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.sensing_of_object_menu.init = function () {
const stage = ScratchBlocks.ScratchMsgs.translate('SENSING_OF_STAGE', 'Stage');
const json = jsonForMenuBlock('OBJECT', spriteMenu, sensingColors, [
[stage, '_stage_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.sensing_of.init = function () {
const blockId = this.id;
// Function that fills in menu for the first input in the sensing block.
// Called every time it opens since it depends on the values in the other block input.
const menuFn = function () {
const stageOptions = [
[ScratchBlocks.Msg.SENSING_OF_BACKDROPNUMBER, 'backdrop #'],
[ScratchBlocks.Msg.SENSING_OF_BACKDROPNAME, 'backdrop name'],
[ScratchBlocks.Msg.SENSING_OF_VOLUME, 'volume']
];
const spriteOptions = [
[ScratchBlocks.Msg.SENSING_OF_XPOSITION, 'x position'],
[ScratchBlocks.Msg.SENSING_OF_YPOSITION, 'y position'],
[ScratchBlocks.Msg.SENSING_OF_DIRECTION, 'direction'],
[ScratchBlocks.Msg.SENSING_OF_COSTUMENUMBER, 'costume #'],
[ScratchBlocks.Msg.SENSING_OF_COSTUMENAME, 'costume name'],
[ScratchBlocks.Msg.SENSING_OF_SIZE, 'size'],
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.motion_glideto_menu.init = function () {
const random = ScratchBlocks.ScratchMsgs.translate('MOTION_GLIDETO_RANDOM', 'random position');
const mouse = ScratchBlocks.ScratchMsgs.translate('MOTION_GLIDETO_POINTER', 'mouse-pointer');
const json = jsonForMenuBlock('TO', spriteMenu, motionColors, [
[random, '_random_'],
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.sensing_of_object_menu.init = function () {
const stage = ScratchBlocks.ScratchMsgs.translate('SENSING_OF_STAGE', 'Stage');
const json = jsonForMenuBlock('OBJECT', spriteMenu, sensingColors, [
[stage, '_stage_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.sensing_of.init = function () {
const blockId = this.id;
// Function that fills in menu for the first input in the sensing block.
// Called every time it opens since it depends on the values in the other block input.
const menuFn = function () {
const stageOptions = [
[ScratchBlocks.Msg.SENSING_OF_BACKDROPNUMBER, 'backdrop #'],
[ScratchBlocks.Msg.SENSING_OF_BACKDROPNAME, 'backdrop name'],
[ScratchBlocks.Msg.SENSING_OF_VOLUME, 'volume']
setBlocks (blocksRef) {
if (!blocksRef) return;
this.blocks = blocksRef;
const workspaceConfig = defaultsDeep({},
CustomProcedures.defaultOptions,
this.props.options
);
// @todo This is a hack to make there be no toolbox.
const oldDefaultToolbox = ScratchBlocks.Blocks.defaultToolbox;
ScratchBlocks.Blocks.defaultToolbox = null;
this.workspace = ScratchBlocks.inject(this.blocks, workspaceConfig);
ScratchBlocks.Blocks.defaultToolbox = oldDefaultToolbox;
// Create the procedure declaration block for editing the mutation.
this.mutationRoot = this.workspace.newBlock('procedures_declaration');
// Make the declaration immovable, undeletable and have no context menu
this.mutationRoot.setMovable(false);
this.mutationRoot.setDeletable(false);
this.mutationRoot.contextMenu = false;
this.workspace.addChangeListener(() => {
this.mutationRoot.onChangeFn();
// Keep the block centered on the workspace
const metrics = this.workspace.getMetrics();
const {x, y} = this.mutationRoot.getRelativeToSurfaceXY();
ScratchBlocks.Blocks.event_whenbackdropswitchesto.init = function () {
const json = jsonForHatBlockMenu(
ScratchBlocks.Msg.EVENT_WHENBACKDROPSWITCHESTO,
'BACKDROP', backdropNamesMenu, eventColors, []);
this.jsonInit(json);
};
ScratchBlocks.Blocks.motion_pointtowards_menu.init = function () {
const mouse = ScratchBlocks.ScratchMsgs.translate('MOTION_POINTTOWARDS_POINTER', 'mouse-pointer');
const json = jsonForMenuBlock('TOWARDS', spriteMenu, motionColors, [
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.motion_goto_menu.init = function () {
const random = ScratchBlocks.ScratchMsgs.translate('MOTION_GOTO_RANDOM', 'random position');
const mouse = ScratchBlocks.ScratchMsgs.translate('MOTION_GOTO_POINTER', 'mouse-pointer');
const json = jsonForMenuBlock('TO', spriteMenu, motionColors, [
[random, '_random_'],
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.motion_glideto_menu.init = function () {
const random = ScratchBlocks.ScratchMsgs.translate('MOTION_GLIDETO_RANDOM', 'random position');
const mouse = ScratchBlocks.ScratchMsgs.translate('MOTION_GLIDETO_POINTER', 'mouse-pointer');
const json = jsonForMenuBlock('TO', spriteMenu, motionColors, [
[random, '_random_'],
[mouse, '_mouse_']
]);
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.sensing_touchingobjectmenu.init = function () {
const mouse = ScratchBlocks.ScratchMsgs.translate('SENSING_TOUCHINGOBJECT_POINTER', 'mouse-pointer');
const edge = ScratchBlocks.ScratchMsgs.translate('SENSING_TOUCHINGOBJECT_EDGE', 'edge');
const json = jsonForMenuBlock('TOUCHINGOBJECTMENU', spriteMenu, sensingColors, [
[mouse, '_mouse_'],
[edge, '_edge_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.control_create_clone_of_menu.init = function () {
const json = jsonForMenuBlock('CLONE_OPTION', cloneMenu, controlColors, []);
this.jsonInit(json);
};
ScratchBlocks.VerticalFlyout.getCheckboxState = function (blockId) {
const monitoredBlock = vm.runtime.monitorBlocks._blocks[blockId];
return monitoredBlock ? monitoredBlock.isMonitored : false;
};
ScratchBlocks.FlyoutExtensionCategoryHeader.getExtensionState = function (extensionId) {
if (vm.getPeripheralIsConnected(extensionId)) {
return ScratchBlocks.StatusButtonState.READY;
}
return ScratchBlocks.StatusButtonState.NOT_READY;
};
const looksColors = ScratchBlocks.Colours.looks;
const motionColors = ScratchBlocks.Colours.motion;
const sensingColors = ScratchBlocks.Colours.sensing;
const controlColors = ScratchBlocks.Colours.control;
const eventColors = ScratchBlocks.Colours.event;
ScratchBlocks.Blocks.sound_sounds_menu.init = function () {
const json = jsonForMenuBlock('SOUND_MENU', soundsMenu, soundColors, []);
this.jsonInit(json);
};
ScratchBlocks.Blocks.looks_costume.init = function () {
const json = jsonForMenuBlock('COSTUME', costumesMenu, looksColors, []);
this.jsonInit(json);
};
ScratchBlocks.Blocks.looks_backdrops.init = function () {
const json = jsonForMenuBlock('BACKDROP', backdropsMenu, looksColors, []);
this.jsonInit(json);
};
ScratchBlocks.Blocks.event_whenbackdropswitchesto.init = function () {
const json = jsonForHatBlockMenu(
ScratchBlocks.Msg.EVENT_WHENBACKDROPSWITCHESTO,
'BACKDROP', backdropNamesMenu, eventColors, []);
this.jsonInit(json);
};
const controlColors = ScratchBlocks.Colours.control;
const eventColors = ScratchBlocks.Colours.event;
ScratchBlocks.Blocks.sound_sounds_menu.init = function () {
const json = jsonForMenuBlock('SOUND_MENU', soundsMenu, soundColors, []);
this.jsonInit(json);
};
ScratchBlocks.Blocks.looks_costume.init = function () {
const json = jsonForMenuBlock('COSTUME', costumesMenu, looksColors, []);
this.jsonInit(json);
};
ScratchBlocks.Blocks.looks_backdrops.init = function () {
const json = jsonForMenuBlock('BACKDROP', backdropsMenu, looksColors, []);
this.jsonInit(json);
};
ScratchBlocks.Blocks.event_whenbackdropswitchesto.init = function () {
const json = jsonForHatBlockMenu(
ScratchBlocks.Msg.EVENT_WHENBACKDROPSWITCHESTO,
'BACKDROP', backdropNamesMenu, eventColors, []);
this.jsonInit(json);
};
ScratchBlocks.Blocks.motion_pointtowards_menu.init = function () {
const mouse = ScratchBlocks.ScratchMsgs.translate('MOTION_POINTTOWARDS_POINTER', 'mouse-pointer');
const json = jsonForMenuBlock('TOWARDS', spriteMenu, motionColors, [
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.looks_backdrops.init = function () {
const json = jsonForMenuBlock('BACKDROP', backdropsMenu, looksColors, []);
this.jsonInit(json);
};
ScratchBlocks.Blocks.event_whenbackdropswitchesto.init = function () {
const json = jsonForHatBlockMenu(
ScratchBlocks.Msg.EVENT_WHENBACKDROPSWITCHESTO,
'BACKDROP', backdropNamesMenu, eventColors, []);
this.jsonInit(json);
};
ScratchBlocks.Blocks.motion_pointtowards_menu.init = function () {
const mouse = ScratchBlocks.ScratchMsgs.translate('MOTION_POINTTOWARDS_POINTER', 'mouse-pointer');
const json = jsonForMenuBlock('TOWARDS', spriteMenu, motionColors, [
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.motion_goto_menu.init = function () {
const random = ScratchBlocks.ScratchMsgs.translate('MOTION_GOTO_RANDOM', 'random position');
const mouse = ScratchBlocks.ScratchMsgs.translate('MOTION_GOTO_POINTER', 'mouse-pointer');
const json = jsonForMenuBlock('TO', spriteMenu, motionColors, [
[random, '_random_'],
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
return [['', '']];
};
const json = jsonForSensingMenus(menuFn);
this.jsonInit(json);
};
ScratchBlocks.Blocks.sensing_distancetomenu.init = function () {
const mouse = ScratchBlocks.ScratchMsgs.translate('SENSING_DISTANCETO_POINTER', 'mouse-pointer');
const json = jsonForMenuBlock('DISTANCETOMENU', spriteMenu, sensingColors, [
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.sensing_touchingobjectmenu.init = function () {
const mouse = ScratchBlocks.ScratchMsgs.translate('SENSING_TOUCHINGOBJECT_POINTER', 'mouse-pointer');
const edge = ScratchBlocks.ScratchMsgs.translate('SENSING_TOUCHINGOBJECT_EDGE', 'edge');
const json = jsonForMenuBlock('TOUCHINGOBJECTMENU', spriteMenu, sensingColors, [
[mouse, '_mouse_'],
[edge, '_edge_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.control_create_clone_of_menu.init = function () {
const json = jsonForMenuBlock('CLONE_OPTION', cloneMenu, controlColors, []);
this.jsonInit(json);
};
ScratchBlocks.VerticalFlyout.getCheckboxState = function (blockId) {
const monitoredBlock = vm.runtime.monitorBlocks._blocks[blockId];
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.motion_goto_menu.init = function () {
const random = ScratchBlocks.ScratchMsgs.translate('MOTION_GOTO_RANDOM', 'random position');
const mouse = ScratchBlocks.ScratchMsgs.translate('MOTION_GOTO_POINTER', 'mouse-pointer');
const json = jsonForMenuBlock('TO', spriteMenu, motionColors, [
[random, '_random_'],
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.motion_glideto_menu.init = function () {
const random = ScratchBlocks.ScratchMsgs.translate('MOTION_GLIDETO_RANDOM', 'random position');
const mouse = ScratchBlocks.ScratchMsgs.translate('MOTION_GLIDETO_POINTER', 'mouse-pointer');
const json = jsonForMenuBlock('TO', spriteMenu, motionColors, [
[random, '_random_'],
[mouse, '_mouse_']
]);
this.jsonInit(json);
};
ScratchBlocks.Blocks.sensing_of_object_menu.init = function () {
const stage = ScratchBlocks.ScratchMsgs.translate('SENSING_OF_STAGE', 'Stage');
const json = jsonForMenuBlock('OBJECT', spriteMenu, sensingColors, [
[stage, '_stage_']
]);
this.jsonInit(json);
};