Discuss Scratch

aspizu
Scratcher
45 posts

goboscript - Convert text code to Scratch blocks, Scratch compiler written in Rust.

goboscript v3.1.0

This release features a refactored pre-processor that fixes several issues, paves the way for new features, and gracefully handles errors.

CONCAT Macro
Joins two tokens into a single token.

CONCAT(LHS, RHS)
# becomes
LHSRHS

CONCAT can be nested, for example:

CONCAT(PREFIX, CONCAT(NAME, SUFFIX))
# becomes
PREFIXNAMESUFFIX

Limitation: Currently, only name tokens can be joined.

Recursive Macros
Recursive macros (macros that reference their own name in their definition) are now handled gracefully. Once a macro is expanded, it is marked as suppressed to avoid re-evaluation in the same substitution pass, preventing hangs and infinite loops.

Parsing Ambiguity: Variable-like vs Function-like Macros
When defining a variable-like macro whose definition starts with a ( token, if the token following is a name, it may be misinterpreted as a function-like macro.
Solution: To ensure proper parsing, additional parentheses are required. For instance, defining %define unit_range (zero,one) now requires extra parentheses:
%define unit_range ((zero,one))

Recommended Conventions for Macros
Function-like Macros: Use these to clearly indicate that the macro expands into an expression (e.g. IS_HOVERED() instead of IS_HOVERED), which avoids confusion with global variables.
Naming: Uppercase naming is recommended for macros.
Constants: For constants, consider using variable declarations (e.g. var EXAMPLE = 2*(3+4); ) if constant-folding optimizations are not required.
codingfire23
Scratcher
41 posts

goboscript - Convert text code to Scratch blocks, Scratch compiler written in Rust.

I find it quite funny how it still looks like scratch even in a text format. Because of that however, i don't really see a point. I guess its more flexible and less restrictive but i don't know since i don't do scratch anymore.
awesome-llama
Scratcher
1000+ posts

goboscript - Convert text code to Scratch blocks, Scratch compiler written in Rust.

codingfire23 wrote:

I find it quite funny how it still looks like scratch even in a text format. Because of that however, i don't really see a point. I guess its more flexible and less restrictive but i don't know since i don't do scratch anymore.
You missed all the mentions of macros, functions with returns, structs, enums, and more.

There's no need to manually create variables in the project editor, you type them and they are created. There are local variables to stay within the scope of the procedure they are a part of.

You can copy-paste code. Find and replace. No more pain of backpacking scripts and finding out they made a mess of variables that require renaming or replacement. You can also include code from other files or libraries.

You can use version control such as Git.

It's very useful. I'm making my next project with it.

Last edited by awesome-llama (March 18, 2025 06:00:48)

codingfire23
Scratcher
41 posts

goboscript - Convert text code to Scratch blocks, Scratch compiler written in Rust.

awesome-llama wrote:

codingfire23 wrote:

I find it quite funny how it still looks like scratch even in a text format. Because of that however, i don't really see a point. I guess its more flexible and less restrictive but i don't know since i don't do scratch anymore.
You missed all the mentions of macros, functions with returns, structs, enums, and more.

There's no need to manually create variables in the project editor, you type them and they are created. There are local variables to stay within the scope of the procedure they are a part of.

You can copy-paste code. Find and replace. No more pain of backpacking scripts and finding out they made a mess of variables that require renaming or replacement. You can also include code from other files or libraries.

You can use version control such as Git.

It's very useful. I'm making my next project with it.
Makes sense why you would use it now. I literally can't read these days XD
gilbert_given_189
Scratcher
1000+ posts

goboscript - Convert text code to Scratch blocks, Scratch compiler written in Rust.

This is a great project! If only there's more blocks implemented…
([variable v] of [Sprite1 v])
Here is one such block. (its opcode is sensing_of with a child sensing_of_object_menu)

Last edited by gilbert_given_189 (March 19, 2025 02:38:59)

aspizu
Scratcher
45 posts

goboscript - Convert text code to Scratch blocks, Scratch compiler written in Rust.

goboscript was one of the first-place winners of FOSS HACK 25, and was awarded a 50,000 Rs. prize. FOSS HACK 25 was a open-source hackathon conducted on 22nd - 23rd February 2025 by the FOSS United Foundation. During the 48-hour hackathon, I had worked on several goboscript issues and feature implementation.
hacktronics
Scratcher
100+ posts

goboscript - Convert text code to Scratch blocks, Scratch compiler written in Rust.

Is there a way to generate blocks xml from a text file, instead of creating a project, direct exe or better wasm. I was hoping to integrate with CodeSkool, a free to use, commercial Scratch mode for Robotics and AI. Instead of generating a whole project, wanted user to just fast type something that will be added to the current project. Creating a whole project has limited use cases.
Minecraft_dog1284
Scratcher
27 posts

goboscript - Convert text code to Scratch blocks, Scratch compiler written in Rust.

YESSSSSSSS PLEASE ADD ST!!!!!!!!!
_E-J_
Scratcher
100+ posts

goboscript - Convert text code to Scratch blocks, Scratch compiler written in Rust.

GOBO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Powered by DjangoBB