Discuss Scratch

Icefan13
Scratcher
100+ posts

Better Custom Blocks

It couldn't really be that much harder than adding custom blocks to begin with. Support. If the ST decides to just add custom round reporters, at least let us put them In Boolean blocks like with
 (item () of [list v]) 
okay? Here's a mockup:
define (my reporter)
{do calculation stuff::grey
}report ()::custom cap

qwertycodechamp90411
Scratcher
100+ posts

Better Custom Blocks

Let's say I wanted a custom boolean block. It would look like this?

definition of <boolean>{
run code to solve stuff
}<boolean> true if <>::looks cap

Last edited by qwertycodechamp90411 (June 27, 2023 21:32:06)


Useful Links: Text Generator ——— Encoders/Decoders (Normal, Case Sensitive) ——— New Math Blocks ——— Comment what next on my profile!
Wait, we’re at 900 million projects? So close to 1 billion projects uploaded to the server!

<((x) ^ ((1) / (y))::operators) = ((y) √ (x)::operators)> // is false if x < 0???
Hi! I'm qwertycodechamp90411. I'm most active on the suggestions forum and the help with scripts forum, because I like to help other people and improve scratch! I like to think I'm good at scratch, but there's a lot I don't know/understand (how on earth do scrolling platformers work lol). As a general rule of thumb, I should have the answer if it's math related, because I'm a very stereotypical nerd when it comes to math.
ninjahanzo
Scratcher
500+ posts

Better Custom Blocks

qwertycodechamp90411 wrote:

Let's say I wanted a custom boolean block. It would look like this?

definition of <boolean>{
run code to solve stuff
}<boolean> true if <>::looks cap
Uh…
define <boolean name>

report <>:: custom cap
or
define <boolean name>
{}(report <>:: custom cap):: custom cap
Either one of these, but
<boolean name:: custom-arg> true if <false:: operators>:: custom cap
can cause confusion if it was that in Snap.

Last edited by ninjahanzo (June 28, 2023 03:15:46)




Make pixel art | C.A. 2 Proposal | 500th post | AY: me and medians 2nd scratch bdays
Be high contrast
____________________________________________________________________________________________________________________
anti-kumquat chip 5000 v2.5.60
siggy protectors hosted here
medians
Scratcher
1000+ posts

Better Custom Blocks


Medians bamboozled by 3.0 (version 3.0): https://scratch.mit.edu/projects/979822351/
hi875230163394: You're similar to valve in that you both hate a certain number…
Scratch 0.x, 1.x, 2.x, 3.x and LogoBlocks Archives
Bamboozlement: https://scratch.mit.edu/studios/33739789
Years on internet: 15 (soon 16)
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 @AdamantOrb @MoongeistBeam @festively @Ampharos_ @straightforwardness
i trolled redcat LOL





if you see this
{what method did you use::control hat
answer on profile ::motion
} ::operators
;
Scratchdev57
Scratcher
100+ posts

Better Custom Blocks

I don't see why not!
qwertycodechamp90411
Scratcher
100+ posts

Better Custom Blocks

medians wrote:

That’s the most clever bump I’ve seen lol. But anyways,

ninjahanzo wrote:

<boolean name:: custom-arg> true if <false:: operators>:: custom cap
can cause confusion if it was that in Snap.

If Boolean is false, it won’t run. If
<boolean name> true if <boolean name>::custom cap
then it will run, as boolean name is boolean name, it is true

Useful Links: Text Generator ——— Encoders/Decoders (Normal, Case Sensitive) ——— New Math Blocks ——— Comment what next on my profile!
Wait, we’re at 900 million projects? So close to 1 billion projects uploaded to the server!

<((x) ^ ((1) / (y))::operators) = ((y) √ (x)::operators)> // is false if x < 0???
Hi! I'm qwertycodechamp90411. I'm most active on the suggestions forum and the help with scripts forum, because I like to help other people and improve scratch! I like to think I'm good at scratch, but there's a lot I don't know/understand (how on earth do scrolling platformers work lol). As a general rule of thumb, I should have the answer if it's math related, because I'm a very stereotypical nerd when it comes to math.
mumu245
Scratcher
1000+ posts

Better Custom Blocks

I think local variables could just be put in the hat.

select this text then press Ctrl+Shift+Down to read more
marsmark
Scratcher
60 posts

Better Custom Blocks

mumu245 wrote:

I think local variables could just be put in the hat.
It would confuse people with function parameters, make it the same as global variables but maybe with different colors or special symbols just like how cloud variables work.

My Projects

Scratch++ | Interpreted coding Engine
An introductory text-based programming language made in Scratch; designed for experienced scratchers; that transforms scratch blocks into text form.
pythonlover1234
Scratcher
1 post

Better Custom Blocks

I also wat to have a reporter block, so I support.
The_Dark_Vampire
New to Scratch
1 post

Better Custom Blocks

101% support! That would be so important
The_Dark_Skeleton
Scratcher
23 posts

Better Custom Blocks

Layout idea:


< > >


define (  max (x) (y) )
if <[x] > [y]> then
return with (x)
else
return with (y)
end

when green flag clicked
say ( max (2)(1))



Scratch cat would say 2 then.
I am a C++ coder, so it is similar to the same thing from C++!

— Darkee
medians
Scratcher
1000+ posts

Better Custom Blocks

Fixed:

The_Dark_Skeleton wrote:

Layout idea:
define (max (x ::custom-arg) (y ::custom-arg) ::custom)
if <(x ::custom-arg) > (y::custom-arg)> then
return with (x ::custom-arg) ::custom cap //if this is returned, the custom block stops
end
return with (y ::custom-arg) ::custom cap //so this cannot run if x was already returned

when green flag clicked
say (max (2)(1) ::custom)

Scratch cat would say 2 then.
The block doesn't really need the “with” part:
define (report (val ::custom-arg) ::custom)
return (val ::custom-arg) ::custom cap
It could also be report, but yeah.

mumu245 wrote:

I think local variables could just be put in the hat.
I think that could create clutter with the actual parameters though or at least get confused with them, so I'm thinking that they should just create it in the block or something.

Medians bamboozled by 3.0 (version 3.0): https://scratch.mit.edu/projects/979822351/
hi875230163394: You're similar to valve in that you both hate a certain number…
Scratch 0.x, 1.x, 2.x, 3.x and LogoBlocks Archives
Bamboozlement: https://scratch.mit.edu/studios/33739789
Years on internet: 15 (soon 16)
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 @AdamantOrb @MoongeistBeam @festively @Ampharos_ @straightforwardness
i trolled redcat LOL





if you see this
{what method did you use::control hat
answer on profile ::motion
} ::operators
;
mumu245
Scratcher
1000+ posts

Better Custom Blocks

medians wrote:

I think that could create clutter with the actual parameters though or at least get confused with them, so I'm thinking that they should just create it in the block or something.

What about this then? I'm thinking of making local variables olive green - some ::#84bd13, as that's unused. We also need true and false booleans.
define is (n) prime? ::reporter
local variables (d ::#84bd13) ::custom
set [d v] to [2] ::#84bd13
repeat until <((d ::#84bd13) * (d ::#84bd13)) > (n)>
if <(n) mod (d ::#84bd13)> then
return <true ::control> and end ::custom
end
end
return <false ::control> and end ::custom

Local variables would be similar to the define hat, with an edit option in the menu.

Last edited by mumu245 (July 13, 2023 15:33:00)


select this text then press Ctrl+Shift+Down to read more
scienceexplorer1
Scratcher
100+ posts

Better Custom Blocks

I don't think I know a single person who doesn't support this idea.

+1

This makes code simpler, easier to understand, and genuinely more efficient and easier to use. For larger scripts this can actually make the entire code less laggy

Be cool
- Chilout -
https://www.youtube.com/watch?v=4uoXbsmEBf4


The future lies ahead of us.

Did you know the universe is immensely filled with vacuum rather then any form of matter inside of it?. Well probably you do …
But here is the thing when andromeda galaxy collides with milky way it is expected that not a single star will collide. Space is space. Matter is in a very very small space.






marsmark
Scratcher
60 posts

Better Custom Blocks

BUMP!

My Projects

Scratch++ | Interpreted coding Engine
An introductory text-based programming language made in Scratch; designed for experienced scratchers; that transforms scratch blocks into text form.
brooc210
Scratcher
100+ posts

Better Custom Blocks

Maybe we could also have a call block like from snap
(call{if<(my variable)=[true]>then
return[Yes]::grey cap
else
return[No]::grey cap
}::control)

Last edited by brooc210 (July 15, 2023 07:05:44)








































what u doing here? go make a new project!

















DON'T click here
brooc210
Scratcher
100+ posts

Better Custom Blocks

brooc210 wrote:

(#2232)

thugatwoary wrote:

(#2232)
The lack of this feature is seriously harmful to Scratch, since it encourages the creation of massive spaghetti reporters. Just look at this:
((x) ^ (min/max (y) ((z) ^ (2) :: custom) :: custom) :: custom)
compared to this absolute gargantuan unreadable mess:
([e^ v] of (([ln v] of (x)) * ((((y) + ([e^ v] of (([ln v] of (z)) * (2)) :: operators)) + ([abs v] of ((y) + ([e^ v] of (([ln v] of (z)) * (2)) :: operators))))/(2))) :: operators)
Probably not the best example as there's little practical use for this script, but you can definitely see the point, and there's definitely cases where it gets worse exponentially, especially once you involve blocks that cannot be made using just reporters so you need massive clunky block workarounds and it becomes a nightmare to do any math using those functions without this feature.
I agree.
Well actually you could just use custom blocks and variables to make it less messy too.







































what u doing here? go make a new project!

















DON'T click here
pkhead
Scratcher
1000+ posts

Better Custom Blocks

i doubt the st would add local variables and such. someone probably already spoke my opinion, but i'm too lazy to search 122 pages of replies to confirm that. Also, local variables can be implemented currently in Scratch by treating a list as a stack, but it isn't very practical because to access local variables, you either have to access variables via list indices, or use a command custom block that, given a variable name, writes the value of it to some variable/list, in which case you still need to use global variables or list indices. I think custom reporters would allow that technique to be practical. Posting a possible implementation, if custom reporters were a thing in Scratch, because i'm extremely bored. Of course it would be slower than if it were implemented into Scratch, but at least it's something.

// The first item of a stack frame is the index to the previous stack frame.
// The second item is the number of variables.
// What follows this header is a sequence of variables, each of which takes up two items.
// The first item of a variable is its name, and the second item is its value.
// Shadowing is not implemented, could be implemented using recursion.
define begin stack frame
add (stack base) to [stack v]
set [stack base v] to (length of [stack v])
add (0) to [stack v]

define close stack frame
repeat ((item ((stack base) + (1)) of [stack v]) * (2))
delete (length of [stack base v]) of [stack v]
end
set [stack base v] to (item (stack base) of [stack v])
delete (length of [stack base v]) of [stack v]
delete (length of [stack base v]) of [stack v]

define (local (name) :: custom)
set [i v] to ((stack base) + (2))
repeat (item ((stack base) + (1)) of [stack v])
if <(item (i) of [stack base v]) = (name)> then
report (item ((i) + (1)) of [stack base v]) :: custom
end
change [i v] by (2)
end
report [] :: custom

define set local (var) to (value)
set [i v] to ((stack base) + (2))
repeat (item ((stack base) + (1)) of [stack v])
if <(item (i) of [stack base v]) = (name)> then
replace item (item ((i) + (1)) of [stack v]) of [stack v] with (value)
stop [this script v]
end
change [i v] by (2)
end
replace item ((stack base) + (1)) of [stack v] with ((item ((stack base) + (1)) of [stack v]) + (1))
add (var) to [stack v]
add (value) to [stack v]

when green flag clicked
begin stack frame :: custom
set local [foo] to [hello] :: custom
set local [bar] to [world] :: custom
say (join (local [foo] :: custom) (local [bar] :: custom))
close stack frame :: custom
marsmark
Scratcher
60 posts

Better Custom Blocks

pkhead wrote:

i doubt the st would add local variables and such. someone probably already spoke my opinion, but i'm too lazy to search 122 pages of replies to confirm that. Also, local variables can be implemented currently in Scratch by treating a list as a stack, but it isn't very practical because to access local variables, you either have to access variables via list indices, or use a command custom block that, given a variable name, writes the value of it to some variable/list, in which case you still need to use global variables or list indices. I think custom reporters would allow that technique to be practical. Posting a possible implementation, if custom reporters were a thing in Scratch, because i'm extremely bored. Of course it would be slower than if it were implemented into Scratch, but at least it's something.

// The first item of a stack frame is the index to the previous stack frame.
// The second item is the number of variables.
// What follows this header is a sequence of variables, each of which takes up two items.
// The first item of a variable is its name, and the second item is its value.
// Shadowing is not implemented, could be implemented using recursion.
define begin stack frame
add (stack base) to [stack v]
set [stack base v] to (length of [stack v])
add (0) to [stack v]

define close stack frame
repeat ((item ((stack base) + (1)) of [stack v]) * (2))
delete (length of [stack base v]) of [stack v]
end
set [stack base v] to (item (stack base) of [stack v])
delete (length of [stack base v]) of [stack v]
delete (length of [stack base v]) of [stack v]

define (local (name) :: custom)
set [i v] to ((stack base) + (2))
repeat (item ((stack base) + (1)) of [stack v])
if <(item (i) of [stack base v]) = (name)> then
report (item ((i) + (1)) of [stack base v]) :: custom
end
change [i v] by (2)
end
report [] :: custom

define set local (var) to (value)
set [i v] to ((stack base) + (2))
repeat (item ((stack base) + (1)) of [stack v])
if <(item (i) of [stack base v]) = (name)> then
replace item (item ((i) + (1)) of [stack v]) of [stack v] with (value)
stop [this script v]
end
change [i v] by (2)
end
replace item ((stack base) + (1)) of [stack v] with ((item ((stack base) + (1)) of [stack v]) + (1))
add (var) to [stack v]
add (value) to [stack v]

when green flag clicked
begin stack frame :: custom
set local [foo] to [hello] :: custom
set local [bar] to [world] :: custom
say (join (local [foo] :: custom) (local [bar] :: custom))
close stack frame :: custom
like you said, it is much slower. but also, if you think something shouldn't be added because it can be hard coded, then I guess list can also be replaced by comma-spliced values in variables.

My Projects

Scratch++ | Interpreted coding Engine
An introductory text-based programming language made in Scratch; designed for experienced scratchers; that transforms scratch blocks into text form.

Powered by DjangoBB