AonymousGuy

There are quite a few improvements I have noticed that could be made to custom blocks.
Please read entire post, especially if you are skeptical about it.

*NOTICE: Some of these are in other topics, but I feel I should mention them here as well.

IDEAS 1 & 2: (Can you guess what they are? )


#1: CUSTOM REPORTER BLOCKS
Custom reporters. If you don't know what a reporter is, here is a helpful wiki article. Basically, these would work similar to how they work in other programming languages. In other languages, it would look something like this:
int getWaffles()
{
if (waffles == tasty)
{
return 20; //This tells you what "getWaffles()" is equal to. So if I were to say x = getWaffles(); x would either be equal to 20 or 0.
}
else
{
return 0;
}
}
So obviously there would need to be some way to return a value.
That is where the “report” block comes in. This is based slightly off of BYOB, which uses the same statement. The reason for this is that report might be easier to understand then return, but it is possible to make it return as well. The bottom report block could be dragged and placed elsewhere in the block. (Thanks @TimothyLawyer for suggesting that!)

So how this would work is that when a custom reporter was used in a block, it would run the code and find the return / report value. If there was none, it would report the value at the bottom.

#2: CUSTOM BOOLEAN BLOCKS
These are obviously the same as custom reporter blocks, but are booleans. A function this could be used for is making a “is a multiple of” block or something similar. They could be used to say “string contains other string” and other functions that are too simple to be made into a full-fledged block, but good enough to make custom.

#3: LOCAL VARIABLES
These would be variables that were completely local to the block. No other part of the program could use them. How would these work?
There are 2 ideas:

This is the first one. But how would this work? Somewhere there would have to be something like a “create local variable” button. Obviously, a “create variable” block wouldn't work so well, because that would make it possible to lag out scratch. However, the idea of getting the set, change, etc. blocks by right clicking and pushing “get block…” is plausible.


I think this is the better solution. How it would work is similar to custom blocks. Only the blocks inside of the C-Block could use the variables. The weird looking variables and lists that look like “+” are just a quick sketch of how the using block could create more than one variable. However, I think it should only be able to hold either variables or lists.

The inspiration for this idea came from a language I use called C#, in which you can say this:
void doStuff()
{
using (int x)
{
do stuff that uses int x
}
do stuff that doesn't use int x
}
I think that maybe these should also have different colors, and they should use the right-click functions to get the other blocks.



NOW: THE ISSUES
There are a few problems with implementing these features.
a) New Scratchers might find them difficult - this is true. When I started doing real line-by-line coding, I found it hard to understand WHY a return value was needed. This was because I was calling the things as functions and not as values - so maybe it would make more sense here.

b) Hard to implement - this is the worst problem. Because they would be hard to use for new scratchers, it is not on the scratch team's list. Also, for custom variables, there would probably have to be a block editor. Otherwise, when would the variables you needed show? When you clicked on the script you were editing? Who knows?

c) Most of these features are already in BYOB, so you can just use that.


THE ADVANTAGES
a) This would allow people to make much more organized projects, make blocks that other scratchers could use to perform well-made functions, and make scripts much easier.

b) This would be a good way to learn about more advanced programming topics.

c) Even if they are in BYOB, it is much more advanced than Scratch, so this would make it easier for more people to learn about this kind of thing.

Firedrake969

Support all! All are used in real coding; why not here?

jontmy00

Support.

DotDash

SUPPORT

meowflash

(unneeded quote text removed by moderator - please keep your posts concise)

Brilliant!

Mrcomputer1

+1
Good idea.

AonymousGuy

meowflash wrote:

*Collapsed*
Brilliant!

Does that mean you support?

cobraguy

I like the Local Variables and have come across a few times when I could have used them. I'm sorta on the fence about this because it would be confusing for new scratchers.

LeadToGold

I support this suggestion as well.

I think the highest priority is the return value. (boolean is sort of a special case of return value).

Function local variables would certainly be useful but the I worry that the implementation would add more confusion for beginning programmers.

Sean

k9lego

Support! And my sister's account @v9lego Supports too! So please add us both to the support list. k9lego

mathfreak231

AonymousGuy wrote:

#1: CUSTOM REPORTER BLOCKS
Not the best mock-up I've ever seen. The oval should be outlined subtly and not colored in, like the define shape. (is this clear)

Also, the return thing shouldn't be at the end; what if I wanted to use if blocks to first report and stop if one condition is true before another? (is this clear)

Otherwise, support.

AonymousGuy

mathfreak231 wrote:

AonymousGuy wrote:

#1: CUSTOM REPORTER BLOCKS
Not the best mock-up I've ever seen. The oval should be outlined subtly and not colored in, like the define shape. (is this clear)

Also, the return thing shouldn't be at the end; what if I wanted to use if blocks to first report and stop if one condition is true before another? (is this clear)

Otherwise, support.

1) The mock-up was rushed - but built from screenshots taken directly from the editor (I used a colored IF … THEN block to make the bar to the side, and a define block and a custom block to build the rest)
2) Well… there are ways around this (especially if there were local variables) but I understand
3) OK.

TheGuyWithTheHat2

Support!

AonymousGuy

12 supporters! Can we get more?

conorb

Nice Information

AonymousGuy

conorb wrote:

Nice Information

Do you support?

TimothyLawyer

1. Support
2. (1) takes care of this with other blocks already in Scratch.
3. I support local variables in principle, but do not see a way to add this to Scratch that is easy enough.

Here is a mock-up extending the idea in (1) for custom reporters in Scratch:



AonymousGuy

TimothyLawyer wrote:

1. Support
2. (1) takes care of this with other blocks already in Scratch.
3. I support local variables in principle, but do not see a way to add this to Scratch that is easy enough.

Here is a mock-up extending the idea in (1) for custom reporters in Scratch:




Thanks for supporting!
Good mock-up art! I wondered how it would be good to implement making new return blocks.

Photoguy77

Supporting!

TimothyLawyer

AonymousGuy wrote:

Thanks for supporting!
Good mock-up art! I wondered how it would be good to implement making new return blocks.
Thank you for this thread and your ideas!

I have been thinking about how to simplify this.

From my mock-up, get rid of the Make a Reporter button and New Reporter dialog box.

Instead:

Add a “Return a value” checkbox to the New Block dialog box. (This could be at the top.)

If “Return value” is checked, the outline of the block becomes a reporter (capsule shaped) both in the dialog box and the define block (and after it is made).

The other change is to the define block. Like in the mock-up, it is a wrap block. And the blue return value cap block is affixed to it.

But the C (wrap) is collapsed so the return cap block is connected, at start, to the top tab of the define block.

Since the return block is connected like a normal stack block, it is obvious to Scratchers they can add new blocks in between.

Since the return block is connected like a normal stack block, it is obvious the definition returns whatever value is in the return cap block, if no other changes are made.

As in the mock-up, the return value cap block can be clicked-and-dragged from the define block to create new cap blocks to use elsewhere in the definition (like blue reporter blocks in Scratch block definitions).

When I get a chance, I'll create new mock-up art.