--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ryan Busby Software Engineer
2501 East 28th Street Suite 111 Signal Hill, CA 90755
gbe...@nfbconsulting.com www.nfbconsulting.com
P Please consider the environment before printing this e-mail.
Important Confidentiality Notice: This email is intended for the use of the addressee(s) only and may contain privileged, confidential, or proprietary information that is exempt from disclosure under law. If you have received this message in error, please inform us promptly by reply e-mail, then delete the e-mail, and destroy any printed copy. Thank you for your cooperation.
--
I'm loading the Blockly javascript files before I'm loading your two files:
<script>
[
"/blocky/js/blockly_compressed.js",
"/blocky/js/msg/messages.js",
"/blocky/js/blocks_compressed.js",
"/blocky/js/javascript_compressed.js",
"/blocky/js/msg/js/en.js",
"/blocky/js/toolbox/objectBlocksCodeGen.js",
"/blocky/js/toolbox/objectBlocksDefs.js"
].forEach(function(src) {
var script = document.createElement('script');
script.src = src;
script.async = false;
document.head.appendChild(script);
});
</script>
When I remove the first line (both in objectBlocksCodeGen.js and objectBlocksDefs.js), then everything seems to be working fine...
Issue 2 - code generation failure
All blocks are nicely displayed in the toolbox:
However when I use the 'property name' block, the code generation fails:
Could it be that the objectBlocksCodeGen.js in your gist is not complete ? I don't find in that file a block for 'object_field' and 'object_create_mutator_top'.
Hope you can find some time to fix this.
Thanks !!
Bart
--
if (typeof Blockly === 'undefined') {
const Blockly = window.Blockly;
}
Hi Mark,Hope you had a nice holiday.About issue 1: Ok, didn't notice that. Will remove them from my toolbox.
About issue 2: Perhaps you can make the code conditionally? Something like this:
if (typeof Blockly === 'undefined') {
const Blockly = window.Blockly;
}By the way, your set of blocks works like a charm for my use case! I need it all over the place.
So a few questions:
- Is this a good idea, or do you think it is more difficult to understand for a user ?
- Do you have a better proposal?
- Is there any chance you might update your blocks on gist? Because I suppose it would become an problem for existing workspaces...
- Or is there a possibility to add two new blocks to your gist? I could add the two new blocks to my toolbox, while others can choose to add the existing two blocks to their toolbox.
Thanks for your input!!Bart
--
fieldBlock.setFieldValue(this.fields[i], 'field_name');
object_get_json: "get property %1 of object %2",
object_set_json: "set property %1 of object %2 to %3",
const objectGetBlockDef = {
"type": "object_get",
"message0": getMessage('object_get_json'),
"args0": [
{
"type": "input_value",
"name": "field_name",
"check": "String",
"align": "RIGHT"
},
{
"type": "input_value",
"name": "object",
"check": "Object",
"align": "RIGHT"
}
],
"inputsInline": false,
"output": null,
"colour": CUSTOM_OBJECT_BLOCK_COLOR,
"tooltip": getMessage('object_get_json_tooltip'),
"helpUrl": ""
};
const objectSetBlockDef = {
"type": "object_set",
"message0": getMessage('object_set_json'),
"args0": [
{
"type": "input_value", // Gewijzigd
"name": "field_name",
"check": "String",
"align": "RIGHT"
},
{
"type": "input_value",
"name": "object_field",
"check": "Object",
"align": "RIGHT"
},
{
"type": "input_value",
"name": "value_field",
"align": "RIGHT"
}
],
"inputsInline": false,
"previousStatement": null,
"nextStatement": null,
"colour": CUSTOM_OBJECT_BLOCK_COLOR,
"tooltip": getMessage('object_set_json_tooltip'),
"helpUrl": ""
};
Blockly.JavaScript['object_get'] = function(block) {
const value_field_name = Blockly.JavaScript.valueToCode(block, 'field_name', Blockly.JavaScript.ORDER_ATOMIC) || '\'\'';
const value_object = Blockly.JavaScript.valueToCode(block, 'object', Blockly.JavaScript.ORDER_ATOMIC);
const code = `${value_object}[${value_field_name}]`;
return [code, Blockly.JavaScript.ORDER_NONE];
};
Blockly.JavaScript['object_set'] = function(block) {
const value_field_name = Blockly.JavaScript.valueToCode(block, 'field_name', Blockly.JavaScript.ORDER_ATOMIC) || '\'\''; /
const value_object_field = Blockly.JavaScript.valueToCode(block, 'object_field', Blockly.JavaScript.ORDER_ATOMIC);
const value_value_field = Blockly.JavaScript.valueToCode(block, 'value_field', Blockly.JavaScript.ORDER_ATOMIC);
return `${value_object_field}[${value_field_name}] = ${value_value_field};\n`;
};
Mark,The shadow blocks is indeed a user-friendly addition. Just what I needed. Thanks for the tip!!!!Everything seems to be working fine now, in the updated version of your gist library:But now I'm a little bit confused that it works fine, since there is some (mutator related) code that I haven't changed:
fieldBlock.setFieldValue(this.fields[i], 'field_name');
Do I need to change those lines also? Because 'field_name' is now no value input anymore...