How to translate scratch3 blocks to js code?

468 views
Skip to first unread message

fu6...@gmail.com

unread,
Apr 13, 2022, 4:38:34 AM4/13/22
to Blockly
Hi group,

I want to get js code in the workspace on Scratch, but workspaceToCode can't work! I found the key code, but still not sure what is the best way to do it.
https://github.com/LLK/scratch-vm/blob/2a9379692f29a1984e779c100781bb1714b9fdd5/src/engine/execute.js#L399 

Any help would be much appreciated.

Regards,
fu6...

Mark Friedman

unread,
Apr 13, 2022, 12:44:36 PM4/13/22
to blo...@googlegroups.com
You should probably contact the Scratch group for the definitive story, but AFAIK Scratch does not generate JavaScript code for their blocks.  They have a virtual machine which directly executes an AST representation of the blocks. This is from the scratch-blocks README:

Unlike Blockly, Scratch Blocks does not use code generators, but rather leverages the Scratch Virtual Machine to create highly dynamic, interactive programming environments. 

-Mark


--
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/37381591-432b-4a77-896d-4509a3c08646n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages