Discuss Scratch

RokCoder
Scratcher
1000+ posts

GitHub revisited



My GitHub tool-chain is now at the point where I use it for all of my Scratch projects. By running a batch file it -
  • downloads the latest sb3 for a project
  • converts all scripts into text
  • extracts all assets (costumes and sound effects)
  • opens GitHub Desktop
  • asks for a commit comment and commits everything to GitHub
** NEW **
  • Now also works with locally stored sb3 files
  • Updated to work with new Scratch API
The entire conversion process is done via JavaScript and PHP so will work on any computer. I've currently only made a batch file that supports Windows. If anyone edits it for other systems then I'll happily add it to the repo.

The setup is extremely simple (assuming you're already a GitHub user). The GitHub repository contains everything you need (which is basically a batch file) and includes full set-up instructions.

It makes it trivial to (a) ensure you always have backups and (b) trackback if problems have been introduced or you want to see how and when changes have been made. The following examples make this clearer.

Examples of commits demonstrating how useful this is

Commit comment: Fixed sound channel 0 (noise) pitch control



Commit comment: Increased the contrast of the project's thumbnail



Example taken from a commit that involved variable values changing

Last edited by RokCoder (Dec. 1, 2024 00:49:42)

TheStrykerJay
Scratcher
100+ posts

GitHub revisited

Wow, neat! This looks extremely useful! Once I get back into making games, I will definitely be taking a closer look at using this.

Last edited by TheStrykerJay (May 21, 2021 14:08:52)

Chiroyce
Scratcher
1000+ posts

GitHub revisited

Wow that's cool! Automating tasks saves a ton of time!
Paddle2See
Scratch Team
1000+ posts

GitHub revisited

Are you using this just to make backups / compare versions? Because the Terms of Use are pretty clear about not sharing projects created with other tools.

TOU wrote:

4.4 You may only submit user-generated projects that were created with (1) the Scratch website editor or (2) an unmodified copy of the Scratch editor compiled from the source code described in Section 5.3. You may not upload any projects that were created, by you or by anyone else, with a modified version of the Scratch editor.
Raihan142857
Scratcher
1000+ posts

GitHub revisited

Paddle2See wrote:

Are you using this just to make backups / compare versions? Because the Terms of Use are pretty clear about not sharing projects created with other tools.

TOU wrote:

4.4 You may only submit user-generated projects that were created with (1) the Scratch website editor or (2) an unmodified copy of the Scratch editor compiled from the source code described in Section 5.3. You may not upload any projects that were created, by you or by anyone else, with a modified version of the Scratch editor.
Why is that in the TOS? Isn't the TOS outdated? Does this mean you can't share projects that were programmed in Turbowarp?
colinmacc
Scratcher
1000+ posts

GitHub revisited

Raihan142857 wrote:

Paddle2See wrote:

Are you using this just to make backups / compare versions? Because the Terms of Use are pretty clear about not sharing projects created with other tools.

TOU wrote:

4.4 You may only submit user-generated projects that were created with (1) the Scratch website editor or (2) an unmodified copy of the Scratch editor compiled from the source code described in Section 5.3. You may not upload any projects that were created, by you or by anyone else, with a modified version of the Scratch editor.
Why is that in the TOS? Isn't the TOS outdated? Does this mean you can't share projects that were programmed in Turbowarp?

It sounds like it, yes.
Also anyone who uses a certain browser extension is breaking the TOU…?
gosoccerboy5
Scratcher
1000+ posts

GitHub revisited

colinmacc wrote:

It sounds like it, yes.
Also anyone who uses a certain browser extension is breaking the TOU…?
well technically they're still using the scratch editor. also referencing https://scratch.mit.edu/discuss/topic/284272/, you're still allowed to use browser extensions.
I think Turbowarp is kind of a grey area though
RokCoder
Scratcher
1000+ posts

GitHub revisited

Paddle2See wrote:

Are you using this just to make backups / compare versions? Because the Terms of Use are pretty clear about not sharing projects created with other tools.
It serves two purposes -
  1. It backs up the sb3 in addition to all individual assets (graphics and/or sound files) so you can always roll back to whichever version you want
  2. It parses the JSON scripts into pseudo code so that they can be used effectively in a source control environment
An example of a project I've worked on using this for backups and diffs can be seen in my GitHub repository here

The first post in the thread shows that it's solely for development purposes allowing you to use GitHub for Scratch projects in the same way you would use it for conventional computer languages. As far as I can see it doesn't contravene any TOU.

Delete the whole post if you must. I made the tool for my own use. It just so happens that I find it so extremely useful that I felt I would offer it to other Scratchers.
colinmacc
Scratcher
1000+ posts

GitHub revisited

gosoccerboy5 wrote:

colinmacc wrote:

It sounds like it, yes.
Also anyone who uses a certain browser extension is breaking the TOU…?
well technically they're still using the scratch editor. also referencing https://scratch.mit.edu/discuss/topic/284272/, you're still allowed to use browser extensions.
I think Turbowarp is kind of a grey area though

But it modifies the scratch editor though. That’s literally what it does.
gosoccerboy5
Scratcher
1000+ posts

GitHub revisited

colinmacc wrote:

But it modifies the scratch editor though. That’s literally what it does.
I guess you're right.
Maximouse
Scratcher
1000+ posts

GitHub revisited

colinmacc wrote:

gosoccerboy5 wrote:

colinmacc wrote:

It sounds like it, yes.
Also anyone who uses a certain browser extension is breaking the TOU…?
well technically they're still using the scratch editor. also referencing https://scratch.mit.edu/discuss/topic/284272/, you're still allowed to use browser extensions.
I think Turbowarp is kind of a grey area though

But it modifies the scratch editor though. That’s literally what it does.
It doesn't modify the editor's source code, which appears to be what the part of ToU is about. And I don't think it's “pretty clear”: it only allows projects created with the online editor (“the Scratch website editor”) or Scratch 1.4 (“an unmodified copy of the Scratch editor compiled from the source code described in Section 5.3” – section 5.3 contains a link to the 1.4 source code). This means that any project created using any version of the offline editor other than 1.4 is technically against the rules. I don't think people often report projects for not being made using Scratch.

Last edited by Maximouse (July 24, 2021 08:51:15)

Greg8128
Scratcher
500+ posts

GitHub revisited

Paddle2See wrote:

Are you using this just to make backups / compare versions? Because the Terms of Use are pretty clear about not sharing projects created with other tools.

TOU wrote:

4.4 You may only submit user-generated projects that were created with (1) the Scratch website editor or (2) an unmodified copy of the Scratch editor compiled from the source code described in Section 5.3. You may not upload any projects that were created, by you or by anyone else, with a modified version of the Scratch editor.

What exactly is the point of this rule, anyway? It seems difficult to enforce in practice if the project isn't too much different from a “regular” project. I assume that its main purpose is to preserve equality by making sure that nobody can gain an advantage from “hacked” blocks or tools like a preprocessor.

Therefore, I think that if the tool doesn't provide abilities in excess of those of the Scratch editor, and doesn't produce a “broken” project, then nobody will be able to tell and nobody will have any reason to care. You could also argue that a text-based format for Scratch makes it much easier to use tools like find-and-replace or even a general-purpose preprocessor. However, if the tool greatly impacts how Scratch code is produced then there should be telltale signs of its use.

However, this is just my interpretation; the ST's interpretation is obviously more important.

NFlex23
Scratcher
1000+ posts

GitHub revisited

I just used this for StackLisp, and it's pretty cool! https://github.com/MystPi/stacklisp

Also, is your sb3 to txt program open-source? I would love to take a look at it.
RokCoder
Scratcher
1000+ posts

GitHub revisited

NFlex23 wrote:

I just used this for StackLisp, and it's pretty cool! https://github.com/MystPi/stacklisp

Also, is your sb3 to txt program open-source? I would love to take a look at it.
I'm glad you've found it useful. I have to admit that I'd hate to work on any large Scratch project without using this. The sb3-to-txt repository isn't open source at this point.
ThemeAndReality
Scratcher
27 posts

GitHub revisited

Thanks for making & sharing this. It's really useful, and I've been having a good play. The ability to version control scripts is great! I have a few observations…

I'm getting an HTTP 403 error when using the sb3-to-txt autosave function. The scripts are generated, but it then fails inside the buildSB3 function:
GET https://cdn.projects.scratch.mit.edu/531881458/ 403 (Forbidden)
I've tried your BBC emulator project in addition to some of my shared projects - same result. Could this be something on my side?

I also noticed a few things in the generated scripts:
  • ‘Change’ is spelt wrong in “Looks.ChengeSizeBy(x);”
  • The ‘Play Note () for () Beats’ Scratch 3 block generates “Music.PlayNote(note ?? - probably legacy function from Scratch 2.0, 1);”
  • Event broadcasts use double quotes around the message name, whereas receives do not, e.g.:
    Event.Broadcast(“title screen”);
    WhenBroadcastReceived(title screen)
    I guess message names are like variable names so shouldn't use quotes in either context?

One last observation - I (foolishly) used colons in some sprite names. The resulting scripts.zip includes filenames including those colons. 7zip extracts them ok, replacing the colons with underscores. But Python's shutil.unpack_archive generates a blank file, whose name is truncated (from the colon onwards). The easy answer is to not use colons in sprite names… but it may be worth substituting them (and other non-filename chars) in the generated script files/zip?
RokCoder
Scratcher
1000+ posts

GitHub revisited

ThemeAndReality wrote:

Thanks for making & sharing this. It's really useful, and I've been having a good play. The ability to version control scripts is great!
It's great to hear it's being used! On a large project I couldn't get by without it but it didn't get a great deal of traction with others. Understandable I suppose considering the general demographic.

ThemeAndReality wrote:

I'm getting an HTTP 403 error when using the sb3-to-txt autosave function. The scripts are generated, but it then fails inside the buildSB3 function:
GET https://cdn.projects.scratch.mit.edu/531881458/ 403 (Forbidden)
I've tried your BBC emulator project in addition to some of my shared projects - same result. Could this be something on my side?
From memory I think this is something I need to fix on my side (possibly broken when the Scratch API was updated). I'll try to get a little time to look into it today.

ThemeAndReality wrote:

I
I also noticed a few things in the generated scripts:
  • ‘Change’ is spelt wrong in “Looks.ChengeSizeBy(x);”
  • The ‘Play Note () for () Beats’ Scratch 3 block generates “Music.PlayNote(note ?? - probably legacy function from Scratch 2.0, 1);”
  • Event broadcasts use double quotes around the message name, whereas receives do not, e.g.:
    Event.Broadcast(“title screen”);
    WhenBroadcastReceived(title screen)
    I guess message names are like variable names so shouldn't use quotes in either context?
Great feedback - thanks!

ThemeAndReality wrote:

I
One last observation - I (foolishly) used colons in some sprite names. The resulting scripts.zip includes filenames including those colons. 7zip extracts them ok, replacing the colons with underscores. But Python's shutil.unpack_archive generates a blank file, whose name is truncated (from the colon onwards). The easy answer is to not use colons in sprite names… but it may be worth substituting them (and other non-filename chars) in the generated script files/zip?
I'll have a ponder about this…
RokCoder
Scratcher
1000+ posts

GitHub revisited

The tool has been updated
  • It is now working properly once again with shared projects
  • It now works with locally stored sb3 Scratch projects
Full instructions can be found over at the GitHub repository

MonkeyBean2
Scratcher
500+ posts

GitHub revisited

Wouldn't it make more sense to just have it work with git?
RokCoder
Scratcher
1000+ posts

GitHub revisited

MonkeyBean2 wrote:

Wouldn't it make more sense to just have it work with git?
I don't think so but I could be wrong.

Is this because you don't want to store your projects in GitHub or because you prefer command-line to GUI?

The only possible negative I see is that you need to install GitHub Desktop but that's not much of an inconvenience. How would working directly with git improve it? With a Scratch project, I always want to view changes before committing and GitHub Desktop gives a nice workflow for comparing image and text files. Are you suggesting the batch file stop short of jumping into GitHub Desktop so the user can diff, commit, push, etc. directly from the command line? Or adding that functionality into the batch file?

This is just me sharing my workflow with the community in case anyone finds it useful (and trying to keep things as simple as possible so that it's accessible to others). Can you elaborate on how working with git would improve this?
logabe
Scratcher
71 posts

GitHub revisited

If you don't mind me asking, how does this compare to ajskateboarder's https://github.com/ajskateboarder/scratch-git? Is there any way to use this locally or with a different remote (i.e https://codeberg.org/, sourcehut, or a self-hosted git server )?

Powered by DjangoBB