Discuss Scratch

cooldude-222
Scratcher
100+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

DARKTHUNDER11 wrote:

WORKAROUND:
message split.
Broadcast mmessage.
Have 2 scripts recieve it at the same time.
read the op this is for custom blocks

Last edited by cooldude-222 (Sept. 12, 2020 22:48:01)

EpicGhoul993
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

DARKTHUNDER11 wrote:

WORKAROUND:
message split.
Broadcast mmessage.
Have 2 scripts recieve it at the same time.

EpicGhoul993 wrote:

cooldude-222 wrote:

Sorry, you have to wait 60 seconds between posts
[Offtopic]Oof rip[/Offtopic]

Anyway, there actually is a quite acceptable workaround, BUT if you use many block combinations there will be lots of duplicated codes.
broadcast [run 1 and 2 v]

when I receive [run 1 and 2 v]
block 1 ::custom

when I receive [run 1 and 2 v]
block 2 ::custom

And, I don't say I give this a No Support,

EpicGhoul993 wrote:

Support.
I only want to point out how the workaround given is not very affective compared to the suggestion block.
  • Mountains of broadcast
    Let's say you are making a wayyyy complex game, and you are forced to have several script parts to run at once. Imagine you having to make 10 broadcasts exactly like the one I give above… you know.
  • Screen refeshing
    As I recently read from a Scratch HWS topic,
    […]boardcasts force the screen to refresh, while cusrom blocks with the tick on “run without screen refresh” don't.
    that leads to some scary times where you do stuff really fast and don't want the player to, like, see the character runs everywhere on the screen, but the refresh ruins everything and you are left scratching your head on how to hide it from the player again.
Here's my opinions on the workaround. Please think before posting “ThErE's A wOrKaRoUnD1!!1!!111!”, and be constructive on the topic.
dimayajonelcid
Scratcher
100+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

DARKTHUNDER11 wrote:

WORKAROUND:
message split.
Broadcast mmessage.
Have 2 scripts recieve it at the same time.
What if it was a custom block? You would need to do tedious work to transfer all of the parameters.
And what if you need to stop both scripts? It’s just not possible.
Byron_Inc
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

When will it say “Hello” if I do the following script:
do {
repeat (10)
next costume
wait (.05) secs
end
}while doing {
glide (1) secs to x: (0) y: (0)
} :: control loop
say [Hello]
?
cooldude-222
Scratcher
100+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

Byron_Inc wrote:

When will it say “Hello” if I do the following script:
do {
repeat (10)
next costume
wait (.05) secs
end
}while doing {
glide (1) secs to x: (0) y: (0)
} :: control loop
say [Hello]
?
I believe it will run after both are done
scratch978654
Scratcher
100+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

Ihatr wrote:

cooldude-222 wrote:

leahcimto wrote:

Support, I have needed this so many times and it would be so helpful for custom blocks
please be constructive
How is this not constructive?
IKR?
MrFluffyPenguins
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

cooldude-222 wrote:

Byron_Inc wrote:

When will it say “Hello” if I do the following script:
do {
repeat (10)
next costume
wait (.05) secs
end
}while doing {
glide (1) secs to x: (0) y: (0)
} :: control loop
say [Hello]
?
I believe it will run after both are done
what if you put a forever loop in it? does it ever do the scripts below?
lovecodeabc
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

https://scratch.mit.edu/projects/424934761/
See inside see it works .
when green flag clicked
1
define 1
...
define 2
...
when green flag clicked
2

Last edited by lovecodeabc (Sept. 16, 2020 18:32:57)

apple502j
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

Technically Impossible.
To have multiple scripts run at the same time, we need to use new threads. That's what broadcasts do - each broadcast receiver has its own thread. Custom blocks don't use threads - it runs in the context of parent thread. In the different thread, you cannot access thread variables (aka custom block arguments). Also, we need to wait until all thread finishes executing so we need to yield. Hey, I re-designed “broadcasts”, right?

Also, thread's top block needs to be a hat block, and needs to have set opcodes, not just arbitrary command block. This makes it impossible to use the argument as a thread.
xXRedTheCoderXx
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

lovecodeabc wrote:

https://scratch.mit.edu/projects/424934761/
when green flag clicked
1
define 1
...
define 2
...
when green flag clicked
2
Bruh, please use words, no-one know what you're trying to say!

Mr_PenguinAlex wrote:

what if you put a forever loop in it? does it ever do the scripts below?
Nope.

cooldude-222 wrote:

I believe it will run after both are done
Correct.

apple502j wrote:

Technically Impossible.
To have multiple scripts run at the same time, we need to use new threads. That's what broadcasts do - each broadcast receiver has its own thread. Custom blocks don't use threads - it runs in the context of parent thread. In the different thread, you cannot access thread variables (aka custom block arguments). Also, we need to wait until all thread finishes executing so we need to yield. Hey, I re-designed “broadcasts”, right?

Also, thread's top block needs to be a hat block, and needs to have set opcodes, not just arbitrary command block. This makes it impossible to use the argument as a thread.
Oh… So should I just close this?
MrFluffyPenguins
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

There's a block that does pretty much the same thing in Snap!
It's called “do in paralell”. It doesn't do it at the exact same time, but it's pretty close.

Last edited by MrFluffyPenguins (Sept. 14, 2020 16:04:39)

cooldude-222
Scratcher
100+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

what if instead of the
do{
}while doing{
} ::control
it is
start{
} ::control
it would start running the script inside and it would also continue to run the script below
xXRedTheCoderXx
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

cooldude-222 wrote:

what if instead of the
do{
}while doing{
} ::control
it is
start{
} ::control
it would start running the script inside and it would also continue to run the script below
Seems interesting - but is it possible?
cooldude-222
Scratcher
100+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

xXRedTheCoderXx wrote:

cooldude-222 wrote:

what if instead of the
do{
}while doing{
} ::control
it is
start{
} ::control
it would start running the script inside and it would also continue to run the script below
Seems interesting - but is it possible?
they have a
launch ((move (10) steps::stack)::grey) ::control
block in snap so yes. i just feel like this would be easier to understand than that
xXRedTheCoderXx
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

cooldude-222 wrote:

xXRedTheCoderXx wrote:

Seems interesting - but is it possible?
they have a
launch ((move (10) steps::stack)::grey) ::control
block in snap so yes. i just feel like this would be easier to understand than that
Hmm… well it seems promising. What do other people think of this idea?
SquirreIstar
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

cooldude-222 wrote:

they have a
launch ((move (10) steps::stack)::ring grey) ::control
block in snap so yes. i just feel like this would be easier to understand than that
FTFY

Last edited by SquirreIstar (Sept. 14, 2020 16:19:00)

MrFluffyPenguins
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

xXRedTheCoderXx wrote:

cooldude-222 wrote:

xXRedTheCoderXx wrote:

Seems interesting - but is it possible?
they have a
launch ((move (10) steps::stack)::grey) ::control
block in snap so yes. i just feel like this would be easier to understand than that
Hmm… well it seems promising. What do other people think of this idea?
I think the “do in parallel” block from Snap! is a lot better.
apple502j
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

Note that Snap! and Scratch 3.0 are totally different. I believe it's based on Scratch 1.4?
cooldude-222
Scratcher
100+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

xXRedTheCoderXx wrote:

cooldude-222 wrote:

xXRedTheCoderXx wrote:

Seems interesting - but is it possible?
they have a
launch ((move (10) steps::stack)::grey) ::control
block in snap so yes. i just feel like this would be easier to understand than that
Hmm… well it seems promising. What do other people think of this idea?
^^^ They don't really seem to like it
xXRedTheCoderXx
Scratcher
1000+ posts

"Run, and run" E block (READ THE ENTIRE OP BEFORE POSTING)

cooldude-222 wrote:

^^^ They don't really seem to like it
Only one person said they preferred the Snap block so far, calm down. Let's just wait a bit. ^^

Powered by DjangoBB