Discuss Scratch

GrumpyCat17
Scratcher
81 posts

Better Custom Blocks

jokebookservice1 wrote:

conwayslife wrote:

jokebookservice1 wrote:

conwayslife wrote:

jokebookservice1 wrote:

Buster_McMuffin wrote:

define (x)^(y)
repeat (y)
set [result] to ((x) * (x))
end
The correct workaround for integers is:
define (x)^(y)
repeat (y)
set [result v] to ((result) * (x))
end

This style of workaround works in this case. However, it does not work if you want a recursive function to call itself twice. I would like something like:
define Recursive Function (input1) (input2)
if <basecase::grey> then
return (something1::grey)::custom
else
return (doSomethingWith (Recursive Function (something2::grey) (something3::grey)::custom) (Recursive Function (something4::grey) (something5::grey)::custom)::grey)::custom
end
There is no easy workaround for this. So in this case, custom reporters would be very helpful.
For example factorial:
define Factorial (input1)
if <(input1) = (0)> then
return (1)::custom
else
return ((input1) * (Factorial ((input1) - (1))::custom)) ::custom
end
Factorial can be done with the workaround, although it is less nice than the custom reporter way:
define Factorial (input1)
if <(input1) = (0)> then
set [result v] to [1]
else
Factorial ((input1) - (1))
set [result v] to ((input1) * (result))
end
The problem occurs with a recursive function that calls itself twice, and does something with the outputs. The second call to the function would override whatever variable you store the first result in.
For example, in this Fibonacci calculator:
define Fib (n)
if <(n) = (0)>
return [0]::custom
else
if <(n) = (1)>
return [1]::custom
else
return ((Fib ((n) - (1))::custom) + (Fib ((n) - (2))::custom))::custom
There is no easy workaround; you cannot store the first value in a variable without it getting overwritten by the second recursive call. You can use lists, but it becomes a nightmare.
(And yes, I know this is a horribly inefficient way of calculating Fibonacci numbers, but it was the simplest example I could think of. Sometimes multiple recursive calls are necessary though. In the Hashlife algorithm (which I coded in Scratch), there is a recursive function that calls itself thirteen times.)
13 times! Wow!
If anybody needs to use lists for the workaround, I have a library for that. But I would like custom reporters ASAP

when gf clicked
if <(Grumpy Cat) = [Awesome!]> then
say [Grumpy Cat For The Win!]
else
Why is there even an else? Grumpy Cat is always Awesome!
end
rc0412
Scratcher
7 posts

Better Custom Blocks

repeat until []
end
rc0412
Scratcher
7 posts

Better Custom Blocks

set [ v] to [ v]
Ziggy741
Scratcher
1000+ posts

Better Custom Blocks

Hi! Please use a separate topic for each suggestion. Thanks!

Note that most of my posts on the forums are from years ago, probably mainly in 2016.


































(Unsolved!) How can you see all the shared projects of a deleted account? And some important context. And something else about it.
Please help me answer that question. (From May 2023)


(I know I may seem desperate, the person who owned the account whose projects I am trying to find had been doing some stuff that might need to get taken down)
24691357
Scratcher
100+ posts

Better Custom Blocks

Almost all support. 1 and 2 fully but for 3 somewhat differently:
block (2)

define block (input)
say (input) for (1) secs
set [input v] to [3] :: custom-arg
say (input) for (1) secs
It will say 2 for one second, then 3 for one second.

Last edited by 24691357 (July 19, 2016 09:46:39)


If it is in India, I'm Indian, including i-words.
24691357
Safe cloud chat https://scratch.mit.edu/projects/116768922/
LP_Play
Scratcher
1000+ posts

Better Custom Blocks

+1

I support them all.

24691357
Scratcher
100+ posts

Better Custom Blocks

bump

If it is in India, I'm Indian, including i-words.
24691357
Safe cloud chat https://scratch.mit.edu/projects/116768922/
24691357
Scratcher
100+ posts

Better Custom Blocks

bump

If it is in India, I'm Indian, including i-words.
24691357
Safe cloud chat https://scratch.mit.edu/projects/116768922/
JavierR100
Scratcher
500+ posts

Better Custom Blocks

Support for all!
define Fib (value1) :: reporter
{
if <(value1) = [0]> then
report [0] :: custom cap
else
if <(value1) = [1]> then
report [1] :: custom cap
else
report ((Fib ((value1) - (1))) + (Fib ((value1) - (2)))) :: custom cap
end
end } (report [] :: custom cap) :: custom cap

My customs Blocks on “Snap!” || search in google HN54FyF4KW27o*YWAD94qjEMLV62+]59 to find all my posts. || “Fantasy Tank Builder” Topic || Diep.io | Official Thread || Geometry Dash name account: "JavierR100". || Geometry Dash Official Topic

Actually, [B]en is my legal name!- Pen, BFB 5

Sorry, I'm gone to roblox now, so Im not able to reply anymore!

JavierR100
Scratcher
500+ posts

Better Custom Blocks

Bumpy Blumpty

My customs Blocks on “Snap!” || search in google HN54FyF4KW27o*YWAD94qjEMLV62+]59 to find all my posts. || “Fantasy Tank Builder” Topic || Diep.io | Official Thread || Geometry Dash name account: "JavierR100". || Geometry Dash Official Topic

Actually, [B]en is my legal name!- Pen, BFB 5

Sorry, I'm gone to roblox now, so Im not able to reply anymore!

Minecratch_project
Scratcher
100+ posts

Better Custom Blocks

Approved

This post is sooo popular, there inclusive duplicates!

when green flag clicked
I will never give you up
Darude Sandstorm
Illuminati
Doge
Doritos
More memes
-xJerryx-
Scratcher
3 posts

Better Custom Blocks

Support (1 & 2)
The_Amaru
Scratcher
100+ posts

Better Custom Blocks

Support!!!1


HOW DO I MAKE A SIGNATURE?!?!

AND PLS FOLOW ME I DO F4F!!11!

THIS IS WROTED BY NOOB SPIRIT!!!
Luigi_master
Scratcher
39 posts

Better Custom Blocks

S u p p o r t

when green flag clicked
say [https://scratch.mit.edu/projects/106614836/] for (2) secs
JavierR100
Scratcher
500+ posts

Better Custom Blocks

B
BU
BUM
BUMP
UMP
MP
P

My customs Blocks on “Snap!” || search in google HN54FyF4KW27o*YWAD94qjEMLV62+]59 to find all my posts. || “Fantasy Tank Builder” Topic || Diep.io | Official Thread || Geometry Dash name account: "JavierR100". || Geometry Dash Official Topic

Actually, [B]en is my legal name!- Pen, BFB 5

Sorry, I'm gone to roblox now, so Im not able to reply anymore!

Cameron_Johnson
Scratcher
100+ posts

Better Custom Blocks

#2

local variables (a)▸
set [a v] to [...]

i recreated literally the entire super mario bros. game in scratch, including the lost levels, AND a level editor where you can make/play your own levels. custom power-ups (boomerang flower, hammer suit, mega mushroom), a dev menu packed with cheats and tweaks to different gameplay mechanics (silhouette mode, crazy lakitu, ridable enemies, pick up shells, unlimited fireballs, super speed, super jump, many many more), custom enemies (para-goomba, fire bros, boomerang bros, para-hammer/fire/boomerang bros, venus fire trap, sideways pirannas), actively updating…
Ravenpaw-Warrior
Scratcher
100+ posts

Better Custom Blocks

Cameron_Johnson wrote:

#2
Sorry, but why did you bump a old topic?

ravenpaw | she/her | virgo


hello! my name is ravenpaw
and i love drawing and
a bunch of other stuff.
if you think of something
i probably like it as well.



The_Amaru
Scratcher
100+ posts

Better Custom Blocks

Ravenpaw-Warrior wrote:

Cameron_Johnson wrote:

#2
Sorry, but why did you bump a old topic?
The most recent post was from a month ago. If it were like eight months, It would count as a necropost.


HOW DO I MAKE A SIGNATURE?!?!

AND PLS FOLOW ME I DO F4F!!11!

THIS IS WROTED BY NOOB SPIRIT!!!
Jonathan50
Scratcher
1000+ posts

Better Custom Blocks

The_Amaru wrote:

If it were like eight months, It would count as a necropost.
I think it would if it was anything more than two months.

Not yet a Knight of the Mu Calculus.
The_Amaru
Scratcher
100+ posts

Better Custom Blocks

Jonathan50 wrote:

The_Amaru wrote:

If it were like eight months, It would count as a necropost.
I think it would if it was anything more than two months.
Oops. My bad.


HOW DO I MAKE A SIGNATURE?!?!

AND PLS FOLOW ME I DO F4F!!11!

THIS IS WROTED BY NOOB SPIRIT!!!

Powered by DjangoBB