Discuss Scratch

Oshawott_X
Scratcher
33 posts

Custom Blocks -Run Without Screen Refresh Problem

My browser / operating system: Windows NT 10.0, Chrome 97.0.4692.99, No Flash versions detected
I had a custom block in https://scratch.mit.edu/projects/633380366/ . So the problem is, in the platform sprite, there is a custom block, code below.
define Decode for save (data)
set [Decoded v] to ()
set [IDX v] to ()
repeat until <<(IDX)=[;]>or<(IDX) = [|]
set [Decoded v] to (join (Decoded) (letter (#) of (data)
change [Counter v] by (1)
set [IDX v] to (letter (Counter) of (data)
end
change [counter v] by (1)
When “Run Without Screen Refresh” is on, the variable “Counter” keeps on going into infinity. I'm sure I coded everything right, so I think this might be a bug in Scratch. The code seems to be missing the “IDX”=; or | because it doesn't stop in the “repeat until” block.
RL1123
Scratcher
1000+ posts

Custom Blocks -Run Without Screen Refresh Problem

You aren't setting the counter variable to anything. Add a
set [counter v] to [1]
before the loop.
Oshawott_X
Scratcher
33 posts

Custom Blocks -Run Without Screen Refresh Problem

rayli1123 wrote:

You aren't setting the counter variable to anything. Add a
set [counter v] to [1]
before the loop.
I did, you have to look at the whole project at https://scratch.mit.edu/projects/633380366/
RL1123
Scratcher
1000+ posts

Custom Blocks -Run Without Screen Refresh Problem

Oshawott_X wrote:

rayli1123 wrote:

You aren't setting the counter variable to anything. Add a
set [counter v] to [1]
before the loop.
I did, you have to look at the whole project at https://scratch.mit.edu/projects/633380366/
Actually, I have. Put the set counter variable into the custom block and remove it from the outer loop because you aren't setting the counter back to one every time that you use the custom block.
Oshawott_X
Scratcher
33 posts

Custom Blocks -Run Without Screen Refresh Problem

rayli1123 wrote:

Actually, I have. Put the set counter variable into the custom block and remove it from the outer loop because you aren't setting the counter back to one every time that you use the custom block.
The script repeats to set the variable back to one!
PLEASE TRY IT WITH SCREEN REFRESH!!!
There is no bug when there is screen refresh
Try editing the custom block to screen refresh
Then try playing the game
RL1123
Scratcher
1000+ posts

Custom Blocks -Run Without Screen Refresh Problem

Oshawott_X wrote:

rayli1123 wrote:

Actually, I have. Put the set counter variable into the custom block and remove it from the outer loop because you aren't setting the counter back to one every time that you use the custom block.
The script repeats to set the variable back to one!
PLEASE TRY IT WITH SCREEN REFRESH!!!
There is no bug when there is screen refresh
Try editing the custom block to screen refresh
Then try playing the game
Next time, you need to specify which variable counter it is because you have the counter variable in almost every sprite and they're different. Also, I've moved the counter block to the MyBlock and your game works just fine.
This is in your platform sprite. Do it for other sprites if necessary.

Last edited by RL1123 (Jan. 26, 2022 02:00:07)

Oshawott_X
Scratcher
33 posts

Custom Blocks -Run Without Screen Refresh Problem

rayli1123 wrote:

Next time, you need to specify which variable counter it is because you have the counter variable in almost every sprite and they're different.
I did!

Oshawott_X wrote:

in the platform sprite,
See?
Here's the thing, the platforms won't re-clone when I do that!
RL1123
Scratcher
1000+ posts

Custom Blocks -Run Without Screen Refresh Problem

I think the main problem with your code is that you're deleting and cloning the clones over and over again. It would be much easier if you just cloned ALL of the costumes at the beginning and then moved them around accordingly.

Powered by DjangoBB