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
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 10. If anyone edits it for other systems then I'll happily add it to the repo.

The set-up is extremely simply (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 absolutely trivial to (a) ensure you always have backups and (b) track back 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 (May 21, 2021 15:02:18)



Scratch dabbling for fun…

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!







April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
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.

Scratch Team Member, kayak and pickleball enthusiast, cat caregiver.

This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.
(credit to Za-Chary)



;
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?

I use scratch.
GF: I'll dump you. BF: hex dump or binary dump?










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…?

Sample Projects

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.


Scratch dabbling for fun…

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.

Sample Projects

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)



This is Maximouse's signature. Learn more about signatures.
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.


My best projects:

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.

Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
  • Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
  • The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
  • Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
  • Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
  • Issues with Scratch itself should be put in Bugs and Glitches.
Before you post: Is what you're posting likely to start an argument or derail the thread (e.g., browsers, operating systems)? If so, please re-think your post!





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.


Scratch dabbling for fun…

ThemeAndReality
Scratcher
13 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?

Try out my games…


…and See Inside afterwards!
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…


Scratch dabbling for fun…

Powered by DjangoBB