Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » My ScratchBlocks interpreter
- Greg8128
-
500+ posts
My ScratchBlocks interpreter
The goal of this project is to allow you to run ScratchBlocks code in text form inside a Scratch project.
Link: https://scratch-mit-edu.ezproxyberklee.flo.org/projects/530232084/
As of right now (May 14, 2021), this project has support for arithmetic and boolean operators, the ‘length of’ and ‘join’ string operators, the ‘set variable’, ‘say’, and ‘ask’ blocks, and the ‘if’, ‘if/else’ and ‘repeat until’ blocks. As a result, it can run the following code:
Features currently not available:
Link: https://scratch-mit-edu.ezproxyberklee.flo.org/projects/530232084/
As of right now (May 14, 2021), this project has support for arithmetic and boolean operators, the ‘length of’ and ‘join’ string operators, the ‘set variable’, ‘say’, and ‘ask’ blocks, and the ‘if’, ‘if/else’ and ‘repeat until’ blocks. As a result, it can run the following code:
say [Hello!] for (2) secs
ask [What's your name?] and wait
say (join [Hello, ] (join (answer) [!])) for (2) secs
if <(length of (answer)) > (6)> then
say [your name is long!] for (2) secs
if <(length of (answer)) > (9)> then
say [Very long!] for (2) secs
end
else
say [Your name is short!] for (2) secs
end
say [Now, watch me count to 10!] for (2) secs
set [counter v] to (1)
repeat until <(counter) > (10)>
say (counter) for (1) secs
set [counter v] to ((counter) + (1))
end
say [Press 'See inside' to enter your own code, and press the green flag to run it!] for (4) secs
Features currently not available:
- Motion, looks, sound, sensing, pen, and other simple blocks: Would take a lot of time due to the sheer number of them. However, it's pretty easy to add new blocks to the existing code. I encourage you to remix and try adding a block
- List blocks: Would require a lot of custom memory management code. Probably not happening
- Receiving messages and multithreading in one sprite: basically impossible
- Clones: Tricky but doable
- Custom blocks: Should be possible
Last edited by Greg8128 (May 15, 2021 03:27:11)
- airplanedodge
-
1000+ posts
My ScratchBlocks interpreter
Interesting! I can do something similar in Snap! (working on a snap blocks to scratchblocks codifier rn)
- Greg8128
-
500+ posts
My ScratchBlocks interpreter
! (working on a snap blocks to scratchblocks codifier rn)Try taking a look at this project for inspiration: Interesting! I can do something similar in Snaphttps://scratch-mit-edu.ezproxyberklee.flo.org/projects/3143066/ Snap! is “Scheme disguised as Scratch” so this should give you a good idea of how a lot of the advanced features in Snap! can be implemented. That being said, it is a bit slow so definitely think about how you can make it faster.
- Discussion Forums
- » Advanced Topics
-
» My ScratchBlocks interpreter