Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Scratch to C++ translation and how to make it better
- medians
-
1000+ posts
Scratch to C++ translation and how to make it better
Are you trying to pretend to be me?What's dragging mode? There is dragging mode now! Yeah
Okay, maybe not lolYeah, this would be pretty confusing to implement in C++. There was a proposal to add this (doc), but it wasn't implemented. The OP can ignore edge cases like these for now, however.when gf clicked
set [num v] to (342)
set [num v] to (join [0o] (num))
change [num v] by (1)
say (num) // 227
Last edited by medians (May 16, 2023 03:24:17)
hi875230163394: You're similar to valve in that you both hate a certain number…
Medians bamboozled by 3.0 (both projects back up): Original and https://scratch.mit.edu/projects/878470775/
Scratch 0.x, 1.x, 2.x, 3.x and LogoBlocks Archives
medians: Oh god not this utc - 12 thing again..
Fun_Cupcake_i81: What, were you expecting not to see the utc - 12 thing again? THE UTC - 12 THIGN ALWAYS RETURNS. ALWAYS.
medians: I knew it would happen. I was the one who started it last year.
Fun_Cupcake_i81: Well then if you didn't want it back maybe you need to time travel to last year and fix that
Oh wait if you could time travel I think we all know exactly when you would go-
user1: That picture is from 2.0. Now he’s at my house and is my pet.
user2: But this is medians we're talking about, so “from 2.0” can mean the same thing as “from five seconds ago”.
Detect Scratch version here
My other accounts: @selfexplanatory @modesties @chaircard @fireflyhero @dividendyield @colloids @radians @skeuamorphism @dihectogon @anglebisector @aau- @EditBlockColors
i trolled redcat LOL
if you see this
{what method did you use::control hat;
answer on profile ::motion
} ::operators
- liavka
-
47 posts
Scratch to C++ translation and how to make it better
WhoAre you trying to pretend to be me?What's dragging mode? There is dragging mode now! YeahOkay, maybe not lolYeah, this would be pretty confusing to implement in C++. There was a proposal to add this (doc), but it wasn't implemented. The OP can ignore edge cases like these for now, however.when gf clicked
set [num v] to (342)
set [num v] to (join [0o] (num))
change [num v] by (1)
say (num) // 227
- WojtekGame
-
1000+ posts
Scratch to C++ translation and how to make it better
when will be the whole project done (and even adding some TW support if you can.)

me on my way for Minecraft…
JS: code-gui | scratch-player | Roost.js | Pandoa | TOP: Roost.js || C++: Gamine | Gamiinuu | TOP: Gamine
Else: Emoji Painter | Forum Shopping Mall | TOP: Emoji Painter || Profile:Scratch | GitHub
Orgs: Chroast | Twerkish | Komond OS | JS Inventions | TOP: JS Inventions || Ocular Naming: 0 | 1 | 2 | 3
Games: Mom Hid My Game! | Creeper Adventuring
else might be outdated or removed by the ST.
- liavka
-
47 posts
Scratch to C++ translation and how to make it better
Idk.. What I can say is I don't think it will be ready in this month. Since there is no sound functions at all. Rn I'm debugging/refactoring it, so that I can move to the next blocks painless. when will be the whole project done (and even adding some TW support if you can.)
But you can check the blocks list. It's growing little by little
https://github.com/MiloLug/c-scratch/blob/main/docs/scratch_functionality.md
- liavka
-
47 posts
Scratch to C++ translation and how to make it better
Phew… Spent another day on improvements and fixes. There are now Const, Var and Arg types for storing values. I thought before that simply passing everything by auto and reference will be enough, but it just started falling apart with more complex code. And at the same time I couldn't make all the arguments into Vars, since it's too heavy to initialize.
And it's safe now to pass any (string/number) data to functions using Arg without overhead of copying strings in some cases etc.
Soo… I think it's time to move to implementing more blocks.
Var test1 = L“lol”;
Corouting testFunction(Arg something) {
test1 = 3;
cs_print(something); // before it would print 3
cs_stop;
}
And it's safe now to pass any (string/number) data to functions using Arg without overhead of copying strings in some cases etc.
Soo… I think it's time to move to implementing more blocks.
Last edited by liavka (May 18, 2023 14:24:20)
- WojtekGame
-
1000+ posts
Scratch to C++ translation and how to make it better
i think we can use std::string though because it's the built-in. Phew… Spent another day on improvements and fixes. There are now Const, Var and Arg types for storing values. I thought before that simply passing everything by auto and reference will be enough, but it just started falling apart with more complex code. And at the same time I couldn't make all the arguments into Vars, since it's too heavy to initialize.Var test1 = L“lol”;
Corouting testFunction(Arg something) {
test1 = 3;
cs_print(something); // before it would print 3
cs_stop;
}
And it's safe now to pass any (string/number) data to functions using Arg without overhead of copying strings in some cases etc.
Soo… I think it's time to move to implementing more blocks.
however numbers can use std::string too, but it's better in a int.

me on my way for Minecraft…
JS: code-gui | scratch-player | Roost.js | Pandoa | TOP: Roost.js || C++: Gamine | Gamiinuu | TOP: Gamine
Else: Emoji Painter | Forum Shopping Mall | TOP: Emoji Painter || Profile:Scratch | GitHub
Orgs: Chroast | Twerkish | Komond OS | JS Inventions | TOP: JS Inventions || Ocular Naming: 0 | 1 | 2 | 3
Games: Mom Hid My Game! | Creeper Adventuring
else might be outdated or removed by the ST.
- liavka
-
47 posts
Scratch to C++ translation and how to make it better
i think we can use std::string though because it's the built-in. Phew… Spent another day on improvements and fixes. There are now Const, Var and Arg types for storing values. I thought before that simply passing everything by auto and reference will be enough, but it just started falling apart with more complex code. And at the same time I couldn't make all the arguments into Vars, since it's too heavy to initialize.Var test1 = L“lol”;
Corouting testFunction(Arg something) {
test1 = 3;
cs_print(something); // before it would print 3
cs_stop;
}
And it's safe now to pass any (string/number) data to functions using Arg without overhead of copying strings in some cases etc.
Soo… I think it's time to move to implementing more blocks.
however numbers can use std::string too, but it's better in a int.
In short, Var (and so Arg, Const) allow to store both numbers and strings.
Actually, I have my own String here, since it allows me to have more control over memory etc. But not only the string. Since storing numbers as strings is just… Strange ._.
I don't use neither std::string nor numbers alone. As I said, there is Var and Arg (Const is just a base for them). And they allow you to store both strings and numbers dynamically. They also manage string-to-number and number-to-string things so you can do
Var t = 0;
t = join(1, t);
t = t + L“20”;
cs_print(t); // prints 30
And with Arg you can do the same (it's just an optimized version of Var for passing values to a function).
Coroutine myFunction(Arg x, Arg y) {
cs_print(x + y);
cs_stop;
}
// they all work fine:
cs_wait myFunction(L“220”, 11);
cs_wait myFunction(1, 2);
cs_wait myFunction(10, L“0xFFF”);
In case you don't know about that L prefix - it's just for unicode strings support.
So the strings and numbers logic is finished. Rn I just need to add the rest of the blocks.
Last edited by liavka (May 18, 2023 15:37:55)
- liavka
-
47 posts
Scratch to C++ translation and how to make it better
Welp, I've made some improvements and now it's able to compile and run on windows with mingw. Both with gcc and clang variants
- liavka
-
47 posts
Scratch to C++ translation and how to make it better
Yo! It works fine for mingw-gcc/-clang and Visual Studio (latest) with Clang-CL or MSVC.
In other words, you can try it now on Windows. You just need the latest Visual Studio or MinGW with CMake.
In Visual Studio you have to enable C++ and CMake tools support.
Then just download the project ( https://github.com/MiloLug/c-scratch ) and open its folder in the studio.
In other words, you can try it now on Windows. You just need the latest Visual Studio or MinGW with CMake.
In Visual Studio you have to enable C++ and CMake tools support.
Then just download the project ( https://github.com/MiloLug/c-scratch ) and open its folder in the studio.
Last edited by liavka (May 24, 2023 07:31:32)
- WojtekGame
-
1000+ posts
Scratch to C++ translation and how to make it better
bumping something due to being written in C++ (it's an flavor i guess)

me on my way for Minecraft…
JS: code-gui | scratch-player | Roost.js | Pandoa | TOP: Roost.js || C++: Gamine | Gamiinuu | TOP: Gamine
Else: Emoji Painter | Forum Shopping Mall | TOP: Emoji Painter || Profile:Scratch | GitHub
Orgs: Chroast | Twerkish | Komond OS | JS Inventions | TOP: JS Inventions || Ocular Naming: 0 | 1 | 2 | 3
Games: Mom Hid My Game! | Creeper Adventuring
else might be outdated or removed by the ST.
- Discussion Forums
- » Advanced Topics
-
» Scratch to C++ translation and how to make it better