Topic Information

Global custom blocks by whiteandblackcat in Suggestions

Posts: 7

1: whiteandblackcat wrote at 2:49:32 AM 29/6/20204172328
I've seen this suggested a few times before but I couldn't find an open topic for it, so I'm making one.

Global custom blocks would work similarly to variables. When you created a custom block, there'd be two options, in the forms of checkboxes: “This sprite only” (default) and “For all sprites”. This sprite only custom blocks would work as they work now; only that particular sprite and its clones can run the block. If you checked “for all sprites”, the custom block would be in the block menu of all sprites.

Only one sprite would have the definition - perhaps the stage, although that could be an issue because the stage has a slightly different block set. Perhaps every sprite could contain the definition, but making edits would send out the new form of the block to other sprites. I don't think there'd be any syncing errors since scratch doesn't and probably never will have multi editing.

There's another possible issue - variables. If you used a “this sprite only” variable in a global custom block, how would it work?
I can see two logical approaches:

Creating a temporary copy of the variable for each sprite, sort of like clones' behaviour with “this sprite only” variables. This variable would be able to be changed by the sprite but no other sprites can read it, and the variable can't be found in the variable list.
OR
Not allowing “this sprite only” variables to be used in global custom blocks and asking the user to choose a global variable.

I think the best option would be a compromise between the two: A popup saying “using a local variable for this script will create a copy of this variable for every sprite that uses the script. The copy will be temporary and won't be able to be viewed by the user or other sprites.” and two buttons; “ok” and “use a different variable” or “cancel”. There would probably also be a “don't show this again” checkbox.

If you used a global variable in a global custom block, I think it would just change a lot. Maybe there could be a warning saying “this variable is global. all sprites can change it. You could run into problems if you run this block from multiple sprites at the same time.” But that would end up being a lot of popups, and could dissuade users if it began to seem like whatever they do, they get a warning they don't understand.
Ideas?
2: whiteandblackcat wrote at 4:42:44 AM 30/6/20204175761
Bump!
3: ResExsention wrote at 4:55:02 AM 30/6/20204175768
Exists on Github already.

Duplicate (of something), too.
4: whiteandblackcat wrote at 5:20:54 AM 30/6/20204175784

ResExsention wrote:

Exists on Github already.

Duplicate (of something), too.
Link? As I said, I couldn't find any open dupes
5: ResExsention wrote at 5:33:28 AM 30/6/20204175796
I wonder why said duplicates were closed?

Still, there is already a Github page so this is–

https://github.com/LLK/scratch-flash/issues/782
6: ResExsention wrote at 5:36:08 AM 30/6/20204175799
Hmm, you're right.

No support. The Github page works; this is technically a duplicate anyway.

Good suggestion, though – I look forward to the day when it'll be added.
7: whiteandblackcat wrote at 5:43:01 AM 30/6/20204175809

ResExsention wrote:

Hmm, you're right.

No support. The Github page works; this is technically a duplicate anyway.

Good suggestion, though – I look forward to the day when it'll be added.
The Github page isn't scratch….

The main topic I found was closed by the topic owner; they were going to make another similar topic asking a different question but left no link to it: https://scratch.mit.edu/discuss/topic/12015/