Discuss Scratch

Cheezzychiknzzz
Scratcher
500+ posts

Official Scratch Workaround Guide VIII

zispe wrote:

ezriha wrote:

zispe wrote:

I believe the already have a workaround that works similarly.
Oh, which one?
4.1, if the two don't do the same thing I don't believe I'll add how to bypass the stop sign clicked, it's very easy to find anywhere on Scratch and I don't think adding something to the topic that openly breaks Scratch is very clever.
Snip!
That workaround doesn't break Scratch it only leaves a UI bug. It's even used openly by Scratchteam in thier Random Idea Generator!
zispe
Scratcher
500+ posts

Official Scratch Workaround Guide VIII

Cheezzychiknzzz wrote:

zispe wrote:

ezriha wrote:

zispe wrote:

I believe the already have a workaround that works similarly.
Oh, which one?
4.1, if the two don't do the same thing I don't believe I'll add how to bypass the stop sign clicked, it's very easy to find anywhere on Scratch and I don't think adding something to the topic that openly breaks Scratch is very clever.
Snip!
That workaround doesn't break Scratch it only leaves a UI bug. It's even used openly by Scratchteam in thier Random Idea Generator!
Break Scratch isn't the best wording, but I couldn't think of how else to say what I meant.

Either way, I do believe (?) 4.1 does work in the same way or in a similar way.
benegam
Scratcher
94 posts

Official Scratch Workaround Guide VIII

Cheezzychiknzzz wrote:

zispe wrote:

ezriha wrote:

zispe wrote:

I believe the already have a workaround that works similarly.
Oh, which one?
4.1, if the two don't do the same thing I don't believe I'll add how to bypass the stop sign clicked, it's very easy to find anywhere on Scratch and I don't think adding something to the topic that openly breaks Scratch is very clever.
Snip!
That workaround doesn't break Scratch it only leaves a UI bug. It's even used openly by Scratchteam in thier Random Idea Generator!
that uses the fact that effects such as the ghost effect reset when you click the stop sign.
Cheezzychiknzzz
Scratcher
500+ posts

Official Scratch Workaround Guide VIII

benegam wrote:

Cheezzychiknzzz wrote:

zispe wrote:

ezriha wrote:

zispe wrote:

I believe the already have a workaround that works similarly.
Oh, which one?
4.1, if the two don't do the same thing I don't believe I'll add how to bypass the stop sign clicked, it's very easy to find anywhere on Scratch and I don't think adding something to the topic that openly breaks Scratch is very clever.
Snip!
That workaround doesn't break Scratch it only leaves a UI bug. It's even used openly by Scratchteam in thier Random Idea Generator!
that uses the fact that effects such as the ghost effect reset when you click the stop sign.
Using ghost effect alone would make the thumbnail show up without hiding the stage monitors. To hide the monitors, they would have to use the other workaround

Last edited by Cheezzychiknzzz (July 15, 2026 02:48:40)

ezriha
Scratcher
40 posts

Official Scratch Workaround Guide VIII

Cheezzychiknzzz wrote:

benegam wrote:

Cheezzychiknzzz wrote:

-snip-
that uses the fact that effects such as the ghost effect reset when you click the stop sign.
Using ghost effect alone would make the thumbnail show up without hiding the stage monitors. To hide the monitors, they would have to use the other workaround
This is actually true I checked (looked smthn like this, comments included)

when green flag clicked
forever // This allows me to detect if the project has been stopped so I can hide the variables once the project stops
reset timer
end

when [timer v] > (0) // This hides variables once the project is stopped
hide variable [activity v]
hide variable [character v]
hide variable [mood v]
hide variable [project type v]
hide list [activity v]
hide list [character v]
hide list [mood v]
hide list [project type v]
Mark4SISB
Scratcher
66 posts

Official Scratch Workaround Guide VIII

zispe wrote:

Hey everyone! I've added a simple template for y'all to get workarounds added, so please use that! I'll probably add the ones that've already been suggested (like the one above), don't worry.
-

Mark4SISB wrote:

-snip-
Thanks for the pointers! I'll check that out soon and fix those up
How's this coming? Just checking in, as I've seen other parts of this get updated. Absolutely no pressure, just making sure this doesn't get forgotten .
zispe
Scratcher
500+ posts

Official Scratch Workaround Guide VIII

Mark4SISB wrote:

zispe wrote:

Hey everyone! I've added a simple template for y'all to get workarounds added, so please use that! I'll probably add the ones that've already been suggested (like the one above), don't worry.
-

Mark4SISB wrote:

-snip-
Thanks for the pointers! I'll check that out soon and fix those up
How's this coming? Just checking in, as I've seen other parts of this get updated. Absolutely no pressure, just making sure this doesn't get forgotten .
It totally did get forgotten! I went through and fixed it up now though (I believe, if I did something wrong please let me know).

Thanks for reminding me ;p
Mark4SISB
Scratcher
66 posts

Official Scratch Workaround Guide VIII

zispe wrote:

It totally did get forgotten! I went through and fixed it up now though (I believe, if I did something wrong please let me know).

Thanks for reminding me ;p
Thanks, looks great!
CK840R30R8
Scratcher
38 posts

Official Scratch Workaround Guide VIII

I have another workaround

Workaround Type: Operators & Sensing
Workaround Title: Number to hexadecimal

Create a local (for this sprite only) variable named “hex-255”

ask [Enter your number between 0 and 255] and wait // I use this block as a demonstration
convert number 0-255 ([floor v] of (answer)) to hexadecimal :: custom // floor removes decimals and converts strings to number 0. You can use any reporter block or a hard coded value depending on your needs.

define convert numbers 0-255 (number-255) to hexadecimal
if <not<<(number-255)<[0]> or <(number-255)>[256]>>> then //Numbers must be in range or this script will be stopped to prevent bugs.
set [hex-255 v] to (letter (([floor v] of ((number-255) / [16])) + [1]) of [0123456789ABCDEF])
set [hex-255 v] to (join (hex-255)(letter ((([floor v] of (number-255)) mod [16]) + [1]) of [0123456789ABCDEF]))
else
set [hex-255 v] to [ERROR: Input number not within range.]
end
(hex-255) // Now has converted numbers to hexadecimal (ex. 255 to FF).

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you’d also like to convert numbers between 0 and 16777215 to hexadecimal, you need all the scripts above to continue.


You need a second local variable called “hex-16777215”

ask [Enter your number between 0 and 16777215] and wait
convert number 0-16777215 ([floor v] of (answer)) to hexadecimal :: custom // floor removes decimals and converts strings to number 0.

define convert numbers 0-16777215 (number-16777215) to hexadecimal
if <not<<(number-16777215)<[0]> or <(number-16777215)>[16777215]>>> then //Numbers must be in range or this script will be stopped to prevent bugs.
convert number 0-255 ([floor v] of ((number-16777215) / [65536])) to hexadecimal :: custom // We do it from left to right.
set [hex-16777215 v] to (hex-255) // The value from the custom block that we used before.
convert number 0-255 ([floor v] of (((number-16777215)/[256])mod[256])) to hexadecimal :: custom
set [hex-16777215 v] to (join (hex-16777215)(hex-255))
convert number 0-255 ([floor v] of ((number-16777215)mod[256])) to hexadecimal :: custom
set [hex-16777215 v] to (join (hex-16777215)(hex-255))
else
set [hex-255 v] to [ERROR: Input number not within range.]

Last edited by CK840R30R8 (Sept. 6, 2026 16:55:37)

Mark4SISB
Scratcher
66 posts

Official Scratch Workaround Guide VIII

CK840R30R8 wrote:

I have another workaround
Rather than use STOP THIS SCRIPT to deal with invalid inputs, it is better programming style to check that the input is valid. You can also add an error message so that the output variable doesn't remain what the previous output was.
define convert numbers 0-255 (number-255) to hexadecimal // If you prefer using a list here, use a definition of this block located in Method 1.
if <<not<[0]>(number-255)>> and <(number-255)<[256]>> then //Numbers must be in range.
set [hex-255 v] to (letter (([floor v] of ((number-255) / [16])) + [1]) of [0123456789ABCDEF])
set [hex-255 v] to (join (hex-255)(letter ((([floor v] of (number-255)) mod [16]) + [1]) of [0123456789ABCDEF]))
else
set [hex-255 v] to [**Error: Value not within range**]
end
CK840R30R8
Scratcher
38 posts

Official Scratch Workaround Guide VIII

Mark4SISB wrote:


Rather than use STOP THIS SCRIPT to deal with invalid inputs, it is better programming style to check that the input is valid. You can also add an error message so that the output variable doesn't remain what the previous output was.
You’re right. The error message & if else is a good idea.

Mark4SISB wrote:

define convert numbers 0-255 (number-255) to hexadecimal // If you prefer using a list here, use a definition of this block located in Method 1.
if <<not<[0]>(number-255)>> and <(number-255)<[256]>> then //Numbers must be in range.
set [hex-255 v] to (letter (([floor v] of ((number-255) / [16])) + [1]) of [0123456789ABCDEF])
set [hex-255 v] to (join (hex-255)(letter ((([floor v] of (number-255)) mod [16]) + [1]) of [0123456789ABCDEF]))
else
set [hex-255 v] to [**Error: Value not within range**]
end
One note about the condition inside your if statement:
Because of
<(number-255 ::custom) < [256]>
you’re allowing numbers that are greater than 255 but still smaller than 256. This means that 255.4 or 255.999… are good to go according to your statement. However, numbers with a maximum of 255 are good to go. Here are two options you can fix this with:
<not <(number-255 ::custom) > [255]>> // Use this instead of <(number) < [256]>
//not greater than 255 is same as equal to or smaller than 255.

<not<<(number-255 :: custom)<[0]> and <(number-255 :: custom)>[255]>>> //Use my statement where I have surrounded my statement with a <not<>> block.
Mark4SISB
Scratcher
66 posts

Official Scratch Workaround Guide VIII

CK840R30R8 wrote:

One note about the condition inside your if statement:
you’re allowing numbers that are greater than 255 but still smaller than 256. This means that 255.4 or 255.999… are good to go according to your statement. However, numbers with a maximum of 255 are good to go.

You're right, that is true. I realized that as I was programming it, but I figured the program would already fail with decimals such as “12.5”, so it wasn't all that important. I did the other boundary at 0 using the NOT method because I figured that the use of “-1” would be less easily understandable to someone reading the program.

However, a more defensive program would look like this:

define convert numbers 0-255 (number-255) to hexadecimal // If you prefer using a list here, use a definition of this block located in Method 1.
if <<<not<[0]>(number-255)>> and <(number-255)<[256]>> and <((number-255) mod (1)) = (0)>> then //Numbers must be integers in range.
set [hex-255 v] to (letter (([floor v] of ((number-255) / [16])) + [1]) of [0123456789ABCDEF])
set [hex-255 v] to (join (hex-255)(letter ((([floor v] of (number-255)) mod [16]) + [1]) of [0123456789ABCDEF]))
else
set [hex-255 v] to [**Error: Value is not an integer within the valid range**]
end

Last edited by Mark4SISB (July 27, 2026 17:25:46)

CK840R30R8
Scratcher
38 posts

Official Scratch Workaround Guide VIII

Mark4SISB wrote:

CK840R30R8 wrote:

One note about the condition inside your if statement:
you’re allowing numbers that are greater than 255 but still smaller than 256. This means that 255.4 or 255.999… are good to go according to your statement. However, numbers with a maximum of 255 are good to go.

You're right, that is true. I realized that as I was programming it, but I figured the program would already fail with decimals such as “12.5”, so it wasn't all that important. I did the other boundary at 0 using the NOT method because I figured that the use of “-1” would be less easily understandable to someone reading the program.

I think decimals are okay with entering this custom block. If you noticed that I use (floor()) blocks in my code which rounds the number down to the nearest whole number. Rounding is already done in the code. You can add ((something :: custom) mod 1) if you want to but I don’t think it’s necessary. And if decimals that are within the range of 0-255 cause bugs in your code, please let me know.

define convert numbers 0-255 (number-255) to hexadecimal // If you prefer using a list here, use a definition of this block located in Method 1.
if <not<<(number-255)<[0]> or <(number-255)>[255]>>> then //Numbers must be in range or this script will be stopped to prevent bugs.
set [hex-255 v] to (letter (([floor v] of ((number-255) / [16]) :: #89F089) + [1]) of [0123456789ABCDEF])
set [hex-255 v] to (join (hex-255)(letter ((([floor v] of (number-255) :: #89F089) mod [16]) + [1]) of [0123456789ABCDEF]))
else
set [hex-255 v] to [ERROR: Input number not within range.]
end
I did some experiments with it and I can confirm that the block already rounds decimal numbers down to the nearest whole number / removes the decimal part of the number (ex. 12.2 —> 12 or 99.99 —> 99).

Last edited by CK840R30R8 (July 28, 2026 07:02:11)

Mark4SISB
Scratcher
66 posts

Official Scratch Workaround Guide VIII

CK840R30R8 wrote:

I think decimals are okay with entering this custom block. If you noticed that I use (floor()) blocks in my code which rounds the number down to the nearest whole number. Rounding is already done in the code. You can add ((something :: custom) mod 1) if you want to but I don’t think it’s necessary. And if decimals that are within the range of 0-255 cause bugs in your code, please let me know.
I did some experiments with it and I can confirm that the block already rounds decimal numbers down to the nearest whole number / removes the decimal part of the number (ex. 12.2 —> 12 or 99.99 —> 99).
You're right. However, the use of floor also means that the limit of 256 (not inclusive) was okay :~P

floor(255.9/16)+1=16

Last edited by Mark4SISB (July 28, 2026 18:09:44)

CK840R30R8
Scratcher
38 posts

Official Scratch Workaround Guide VIII

Mark4SISB wrote:

CK840R30R8 wrote:

I think decimals are okay with entering this custom block. If you noticed that I use (floor()) blocks in my code which rounds the number down to the nearest whole number. Rounding is already done in the code. You can add ((something :: custom) mod 1) if you want to but I don’t think it’s necessary. And if decimals that are within the range of 0-255 cause bugs in your code, please let me know.
I did some experiments with it and I can confirm that the block already rounds decimal numbers down to the nearest whole number / removes the decimal part of the number (ex. 12.2 —> 12 or 99.99 —> 99).
You're right. However, the use of floor also means that the limit of 256 (not inclusive) was okay :~P

floor(255.9/16)+1=16
Good catch! I somehow didn’t notice that. I’m not gonna edit my previous posts, but if you or anyone else prefers, you can also use

<<not<(number-255 :: custom)<[0]>> and <(number-255 :: custom)<[256]>>

and/or

<<not<(number-16777215 :: custom)<[0]>> and <(number-16777215 :: custom)<[16777216]>>

Last edited by CK840R30R8 (July 28, 2026 19:23:45)

bitmap_caketin
Scratcher
100+ posts

Official Scratch Workaround Guide VIII

Workaround Type: Events & Control (specifically events)
Workaround Title: ‘every (x) frames’
Method: Timer reset block frame checker
Description:
when [timer v] > (0)
wait (0) seconds
reset timer
change [frames v] by (1)
if <((frame) mod (20))=[0]> then
broadcast (20 frames v)
end
if <((frame) mod (30))=[0]> then
broadcast (30 frames v)
end
if <((frame) mod (40))=[0]> then
broadcast (40 frames v)
end
when I receive (40 frames v)
...
Every time the timer resets, the timer increments above zero.
Therefore this script runs every frame. Each time it runs it increases the frames variable by one, and when it becomes a multiple of x (every x frames) it senfs a broadcast to run the code.

Credit to _nix for debugging

Last edited by bitmap_caketin (Aug. 31, 2026 14:34:23)

_nix
Scratcher
1000+ posts

Official Scratch Workaround Guide VIII

bitmap_caketin wrote:

Workaround Type: Events & Control (specifically events)
Workaround Title: ‘every (x) frames’
Method: Timer reset block frame checker
Description:
when [timer v] > (0)
wait (0) seconds
reset timer
change [frames v] by (1)
broadcast (frame v)
when I receive (frame v)
if <((frame) mod (x))=(0)> then
...
end
Every time the timer resets, the timer increments above zero.
Therefore this script runs every frame. Each time it runs it increases the frames variable by one, and when it becomes a multiple of x (every x frames) it runs the code.
As an alternative method, you can also just use a “when green flag clicked, forever” block to skip the timer code, although that would only work as long as the project is running: once the stop sign is clicked, the loop stops, the frames stop being counted, and the “frame” broadcast stops being sent.

More of an issue, though: Your workaround won't work if the code inside “when I receive frame” itself takes more than one frame to run. “When I receive” scripts are restarted midway through the same broadcast is sent out again, while the “when I receive” is running. And your code sends the “frame” broadcast every single frame, so receiving scripts must be completed within 1 frame or else they will be canceled midway through. (On the next frame, “frame mod x” will no longer be 0, so the script won't even restart from the beginning.)

Instead I recommend something like this. Don't broadcast every frame - just broadcast (distinct messages) on each of the specific multiples you want to count:

when [timer v] > (0)
wait (0) seconds
reset timer
change [frames v] by (1)
if <((frames) mod (20)) = [0]> then
broadcast [every 20 frames v]
end
if <((frames) mod (30)) = [0]> then
broadcast [every 30 frames v]
end
if <((frames) mod (240)) = [0]> then
broadcast [every 240 frames v]
end

when I receive[ every 20 frames v]
...
bitmap_caketin
Scratcher
100+ posts

Official Scratch Workaround Guide VIII

_nix wrote:

*snip*
Thanks, I'll change it.
zispe
Scratcher
500+ posts

Official Scratch Workaround Guide VIII

bitmap_caketin wrote:

Workaround Type: Events & Control (specifically events)
Workaround Title: ‘every (x) frames’
Method: Timer reset block frame checker
Description:
when [timer v] > (0)
wait (0) seconds
reset timer
change [frames v] by (1)
if <((frame) mod (20))=[0]> then
broadcast (20 frames v)
end
if <((frame) mod (30))=[0]> then
broadcast (30 frames v)
end
if <((frame) mod (40))=[0]> then
broadcast (40 frames v)
end
when I receive (40 frames v)
...
Every time the timer resets, the timer increments above zero.
Therefore this script runs every frame. Each time it runs it increases the frames variable by one, and when it becomes a multiple of x (every x frames) it senfs a broadcast to run the code.

Credit to _nix for debugging
Added! Sorry that it took so long, I've been busy.. mostly taking after-school naps.

Powered by DjangoBB