Skip to content

Commit

Permalink
Load Custom Blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Aug 10, 2022
1 parent 996f37c commit 5204bbc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions demos/code/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,26 @@ Code.init = function() {

Code.loadBlocks('');

//// TODO: Added code here
// Load the Zig Custom Blocks.
var blocks = Blockly.Zig.blocks; // From generators/zig/zig_blocks.js
// For each Block...
blocks.forEach(block => {
// Register the Block with Blockly.
Blockly.Blocks[block.type] = {
init: function() {
this.jsonInit(block);
// Assign 'this' to a variable for use in the tooltip closure below.
var thisBlock = this;
// this.setTooltip(function() {
// return 'Add a number to variable "%1".'.replace('%1',
// thisBlock.getFieldValue('VAR'));
// });
}
};
});
//// End of added code

if ('BlocklyStorage' in window) {
// Hook a save function onto unload.
BlocklyStorage.backupOnUnload(Code.workspace);
Expand Down

0 comments on commit 5204bbc

Please sign in to comment.