Using /@blockly/block-shareable-procedures

193 views
Skip to first unread message

Pia Achigar

unread,
Oct 24, 2023, 6:33:37 PM10/24/23
to Blockly
Hi everybody,
I´m trying to use shareable-procedures, but I can't overwrite them, 
I couldn't configure it the way I need it,  yet.

1 - I need to overwrite the json toolbox of the  procedures_defnoreturn
2 - I need to delete / destroy procedures_defreturn



Firts try for overwrite the jsonTool:

     - var varDefNoRet = Blockly.Blocks.procedures_defnoreturn.init;        var json= { ...}        Blockly.workspace.updateBlock(varDefNoRet, json);
but updateBlock, does not exist.

Second try:
I already try with an IIFE:
(function(){var old = Blockly.Blocks.procedures_defnoreturn.init;
Blockly.Blocks.procedures_defnoreturn.init = function(){old.call(this);
this.setMutator(undefined); this.jsonInit( { ... })
};})()

(function() {
  // Elimina el bloque 'procedures_defreturn' de Blockly.Blocks
  //delete Blockly.Blocks.procedures_defreturn;
 
  // Elimina el bloque 'procedures_callreturn' de Blockly.Blocks
  //delete Blockly.Blocks.procedures_callreturn;
})();


Third try:

Blockly.Blocks.procedures_defreturn.init = function(){
varDefRet.call(this); this.setMutator(undefined); this.disabled = true; }
 this.jsonInit( { ... }) }


Is there a method that hits those blocks directly?
Has anyone already tried to do it?
Could you please help me?

Thank you so much!!!

Pía

Christopher Allen

unread,
Oct 25, 2023, 6:36:07 PM10/25/23
to blo...@googlegroups.com
Hi Pia,

I´m trying to use shareable-procedures, but I can't overwrite them, 
I couldn't configure it the way I need it,  yet.

I'm not quite sure what you're trying to do, but have you seen the instructions about how to use the shareable procedure blocks?  In particular, once you've installed the plugin package all you need to do to get the blocks set up and loaded into Blockly is:

import Blockly from 'blockly';
import {blocks, unregisterProcedureBlocks} '@blockly/block-shareable-procedures';

unregisterProcedureBlocks();
Blockly.common.defineBlocks(blocks); 

1 - I need to overwrite the json toolbox of the  procedures_defnoreturn
2 - I need to delete / destroy procedures_defreturn

Are you creating custom procedure blocks?  If so you can just:

  • Optionally call unregisterProcedureBlocks to get rid of the legacy non-shareable procedure blocks.
  • Install your custom definitions using (e.g.) Blockly.Blocks['my_procedure_def'] = { /* block definition */ }; and Blockly.Blocks['my_procedure_call'] = { /* block definition */ }; and then 
  • Add your custom blocks to the toolbox.
Firts try for overwrite the jsonTool:

     - var varDefNoRet = Blockly.Blocks.procedures_defnoreturn.init;        var json= { ...}        Blockly.workspace.updateBlock(varDefNoRet, json);
but updateBlock, does not exist.

Indeed it does not.  What are you trying to achieve here?

Is there a method that hits those blocks directly?
Has anyone already tried to do it?
Could you please help me?

I think it would be easier for us to help you if you can explain what you are trying to achieve, rather than how you are trying to achieve it.  Even after looking at your source code snippets I still do not understand what your goal is, which makes it difficult to help guide you to it.


Christopher

Reply all
Reply to author
Forward
0 new messages