Discuss Scratch

sciclass
Scratcher
2 posts

how to add a custom block on scratch-vm

scratch-vm is a great project . but when i using it .i meet some questions about adding custom block on it .

in playground.js: i add a block like this

window.Blockly.Blocks = {
init: function() {
this.appendDummyInput()
.appendField(“test”);
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setColour(210);
this.setTooltip('');
this.setHelpUrl('http://www.example.com/');
}


in Scratch3MotionBlocks i add the block config

Scratch3MotionBlocks.prototype.getPrimitives = function () {
return {
motion_test: this.smove,
motion_movesteps: this.moveSteps,
motion_gotoxy: this.goToXY,
motion_goto: this.goTo,
motion_turnright: this.turnRight,
motion_turnleft: this.turnLeft,
motion_pointindirection: this.pointInDirection,
motion_pointtowards: this.pointTowards,
motion_glidesecstoxy: this.glide,
motion_ifonedgebounce: this.ifOnEdgeBounce,
motion_setrotationstyle: this.setRotationStyle,
motion_changexby: this.changeX,
motion_setx: this.setX,
motion_changeyby: this.changeY,
motion_sety: this.setY,
motion_xposition: this.getX,
motion_yposition: this.getY,
motion_direction: this.getDirection
};
};

Scratch3MotionBlocks.prototype.test = function (args, util) {
var steps = Cast.toNumber(args.STEPS);
var radians = MathUtil.degToRad(90 - util.target.direction);
var dx = steps * Math.cos(radians);
var dy = steps * Math.sin(radians);
util.target.setXY(util.target.x + dx, util.target.y + dy);
};


but when i running the server ,i cant find the my custom block?

so i dont' know what happen, need i modify the scratch-block' code?
what should i do slove it? million of thx
NitroCipher
Scratcher
100+ posts

how to add a custom block on scratch-vm

sciclass wrote:

scratch-vm is a great project . but when i using it .i meet some questions about adding custom block on it .

in playground.js: i add a block like this

window.Blockly.Blocks = {
init: function() {
this.appendDummyInput()
.appendField(“test”);
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setColour(210);
this.setTooltip('');
this.setHelpUrl('http://www.example.com/');
}


in Scratch3MotionBlocks i add the block config

Scratch3MotionBlocks.prototype.getPrimitives = function () {
return {
motion_test: this.smove,
motion_movesteps: this.moveSteps,
motion_gotoxy: this.goToXY,
motion_goto: this.goTo,
motion_turnright: this.turnRight,
motion_turnleft: this.turnLeft,
motion_pointindirection: this.pointInDirection,
motion_pointtowards: this.pointTowards,
motion_glidesecstoxy: this.glide,
motion_ifonedgebounce: this.ifOnEdgeBounce,
motion_setrotationstyle: this.setRotationStyle,
motion_changexby: this.changeX,
motion_setx: this.setX,
motion_changeyby: this.changeY,
motion_sety: this.setY,
motion_xposition: this.getX,
motion_yposition: this.getY,
motion_direction: this.getDirection
};
};

Scratch3MotionBlocks.prototype.test = function (args, util) {
var steps = Cast.toNumber(args.STEPS);
var radians = MathUtil.degToRad(90 - util.target.direction);
var dx = steps * Math.cos(radians);
var dy = steps * Math.sin(radians);
util.target.setXY(util.target.x + dx, util.target.y + dy);
};


but when i running the server ,i cant find the my custom block?

so i dont' know what happen, need i modify the scratch-block' code?
what should i do slove it? million of thx

How do you set up the scratch vm in the first place?

I hope my post helped you in some way! Post count: 400+

Current project: [s3Blocks: scratchblocks rewritten for Scratch 3.0] ::extension //https://scratch.mit.edu/discuss/topic/290031/
This is my signature identifier “aWFtbml0cm9jaXBoZXI=”
mewtaylor
Scratcher
100+ posts

how to add a custom block on scratch-vm

NitroCipher wrote:

How do you set up the scratch vm in the first place?

Check out the readme on the repo to find out – https://github.com/LLK/scratch-vm. If you're having any trouble with that, definitely let me know and I'll see if I can help!
CodingGamerHD
Scratcher
62 posts

how to add a custom block on scratch-vm

NitroCipher wrote:

-snip-

How do you set up the scratch vm in the first place?
There's an online version here.

EDIT: Whoops, that's the VM. THIS is the real version.

Last edited by CodingGamerHD (Jan. 13, 2017 19:39:22)


> Console.Write(get_os_ver(););
Running Ubuntu 16.10 (64-bit)/Windows 7 Ultimate SP1 (64-bit) (lives on as a VirtualBox VM)/Android 6.0, Google Chrome (no flash)
> Process.Start("https://scratch.mit.edu/users/CodingGamerHD/"); // Check out my projects!
> while (true) { Sharpy.Eat(new Kumquat.Evil(); }// This is my new pet Sharpy, Sharpy protects my siggy from siggy eating kumquats (alongside javascripty) by eating them! Payback, amirite?
>_
;
connor24
Scratcher
3 posts

how to add a custom block on scratch-vm

There is 1 problem I see with your code:

1. You did not add the block to the toolbox, if you check Blockly.Blocks.defaultToolbox, you can add blocks. To see this variable, go to the scratch-blocks repo and go to blocks_vertical/default_toolbox.js
TerryTissue
Scratcher
2 posts

how to add a custom block on scratch-vm

w h at

Powered by DjangoBB

Standard | Mobile