Skip to content

Text To Blocks - can not fine define  #59

@ajtwlsdlqp

Description

@ajtwlsdlqp

hello, Thanks for share nice library

I'm try to porting a BlockMirror to our block coding system based on blockly.
i thnks almost done, and working well... but some problem is accured
oh, i used releases 0.0.1 version code, Skulpt also used latest releases version

when, i creat block from toolbox.. python code is make well what i defined.
but python code to block is not working well..

like this
image

It is shown as the same code, and matches perfectly down to the case.
However, the block taken out of the toolbox (upper pink) and the converted python code into a block (lower dark blue) are different.

this is my test code...

`

BlockMirrorTextToBlocks.BLOCKS.push({
"type": "ast_PlayRbVoice",
"message0": "Say %1 Test",
"args0": [{
"type": "input_value",
"name": "voice"
}],
"previousStatement": null,
"nextStatement": null,
"colour": "#D65CD6",
"tooltip": "%{BKY_PLAY_MELODY_TOOLTIP}",
"helpUrl": ""
});

Blockly.Python['ast_PlayRbVoice'] = function (block) {
var argument0 = Blockly.Python.valueToCode(block, 'voice', Blockly.Python.ORDER_ATOMIC) || Blockly.Python.blank;

console.log("Blockly.Python['ast_PlayRbVoice']");
console.log(argument0);
var code = ('playRbVoice(' + argument0 + ')\n');

return code;
};

BlockMirrorTextToBlocks.prototype['ast_PlayRbVoice'] = function (node, parent) {

var target = node.voice;
console.log("Text to Block ast_PlayRbVoice");
var blockName = 'ast_PlayRbVoice';
//BlockMirrorTextToBlocks.create_block = function (type, lineNumber, fields, values, settings, mutations, statements) {
return BlockMirrorTextToBlocks.create_block(blockName, node.lineno, {}, {"voice": this.convert(target, node) }, {}, {}, {});
};

`

this is event log...
image

in this function "BlockMirrorTextToBlocks.create_block" when i changed forcely blockName to "ast_PlayRbVoice", i can checked block made well

so that, i think the reason of this issue is "BlockMirrorTextToBlocks.prototype['ast_PlayRbVoice'] " this function dosen't called anywhere

please, let me know process to add new block
and if i solved this problem, when i make block to python
the "tab" works well?

i means that, in test example
class X:
'''
Hello world
'''
def add(self, a, b):
a = 0
return a

In the example, when converting a block to Python code, you can see that the code is accurately separated by tab intervals.
However, the converted code on my system is not properly indented and just comes out with newlines.
We appreciate your feedback.

Best Regards, Empe : )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions