Start blocks

446 views
Skip to first unread message

Tuan Ahmad Wafiq

unread,
Jan 15, 2023, 2:57:57 AM1/15/23
to Blockly
Hey, so I have a custom block which is start_block, and I want to make this blocks a parent block which is when my other blocks are not connected to this block, the code cannot be executed, just like the Minecraft Aquatic Voyage in code.org. And I already make it like mentioned in this conversation: https://developers.google.com/blockly/guides/create-custom-blocks/block-paradigms#configuration

The code works fine where my other block will be disabled if it is not connected to this start_block, but since my start block is a custom block, and I still don't have the function written in my code for this block, my other block whose connected to this block cannot run. do you have any suggestion on what code I can put for the start_block function?

what code can I put here:
Blockly.JavaScript['start_block'] = function (block) {
  var code = '...;\n';
  return code;
}

Btw, I'm making a game like blockly maze, and I noticed blockly maze doesn't have start block but the code.org, vex code and scratch have this block, so it is hard for me to refer 

Neil Fraser

unread,
Jan 16, 2023, 6:14:12 AM1/16/23
to blo...@googlegroups.com
Is your start block a block that sits on top of a stack, or a block that encloses a stack?

If it looks like this,
Screenshot 2023-01-16 at 12.09.13.png
then your generator function would look like this:
  return '';


If it looks like this,
Screenshot 2023-01-16 at 12.09.38.png
then your generator function would look like this:
  return JavaScript.statementToCode(block, 'DO');
(Where 'DO' is the name of the statement input on the block.)


--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/61178c18-7a81-4350-a5d1-89a58f8777c8n%40googlegroups.com.


--
Neil Fraser, Switzerland
https://neil.fraser.name

Tuan Ahmad Wafiq

unread,
Jan 19, 2023, 3:45:33 AM1/19/23
to Blockly
hey Neil, it is like the first one. and its work, Thank you so much
Reply all
Reply to author
Forward
0 new messages