Discuss Scratch

The_Cool_Test_Alt
Scratcher
100+ posts

Scratch Workaround Guide VII

Wait, it happens because the sound blocks are “motion-causing”, right? Well, we could just put the set volume in a run-without-screen-refresh block, right?

WHY MUST SOUND BLOCKS CAUSE ACTUAL WAITS?!?! WHY ARE THE SOUND BLOCKS SO MEAN TO US?!?!

Last edited by The_Cool_Test_Alt (Nov. 5, 2025 21:41:46)

CodeComet6161
Scratcher
1000+ posts

Scratch Workaround Guide VII

here's something that triggered me:
Visit the project! This is a simple context menu example which uses variables and a "when stage clikced" block (in the Stage) to detect clicking twice within a short time. Note that the Stage includes two example scripts, one which disables the context menu under certain backdrops and one which doesn't, so you'll have to choose the one which works for your project or remove one if you want to try it out.
Olivia_AM
Scratcher
100+ posts

Scratch Workaround Guide VII

Here is a better power block:
define (x)^(y)
if <(x)<(0)> then
set [result v] to (([e^ v] of ((y)*([ln v] of ((0)-(x))))::operators)*([cos v] of ((180)*(y)
else
set [result v] to ([e^ v] of ((y)*([ln v] of (x)))::operators

Last edited by Olivia_AM (Nov. 10, 2025 13:05:58)

The_Cool_Scratch_Guy
Scratcher
100+ posts

Scratch Workaround Guide VII

What's cos(y*180) for??
UserBlockedYou
Scratcher
52 posts

Scratch Workaround Guide VII

Cheezzychiknzzz wrote:

After reading the table of contents, I realized that there isn't a Workaround for the sounds category blocks, which is surprising since every other category has been covered. So I figured I would give my suggestion (note, this trick has been widely known & used. However I suggested it to make the list feel more complete and for people who do not know it) This is for the
pause sound:: sound
and
unpause sound:: sound
——————————————————————-
(I'l be setting u & p for the unpause and pause keys respectively but you can set the keys to anything you'd like or you can start the scripts with a broadcast or any other trigger)
You could just do
when [p v] key pressed
set volume to (0) %
and
when [u v] key pressed
set volume to (100) %
for the pause and unpause blocks respectively, but if you want the sound to start where it was stopped, you can do
when [p v] key pressed
set [pitch v] effect to ((-1) / (0))
set volume to (0) %
and
when [u v] key pressed
set [pitch v] effect to (100)
set volume to (100) %
The
((-1) / (0)) 
block gives you -Infinity and “pitch” doesn't just lower the pitch but the lowers the speed of the sound so when the earlier equation is used for the pitch, it makes the sound s u p e r s l o w and the set volume to (0) % block hides the slowed down sound and finally the latter script reverses the effect of the former script.
should be set pitch to 0 not 100
wallaceji
New Scratcher
7 posts

Scratch Workaround Guide VII

_nix wrote:


Scratch Workaround Guide Ⅶ
༺༻




If you’ve spent some time programming with Scratch, there is a pretty good chance that you’ve gone looking for a block which just doesn’t exist—some kind of action or utility that you can’t find in any of the existing blocks! The Scratch Team tries to keep the list of blocks minimal, so that it isn’t overwhelming or confusing for newer Scratchers (among several other reasons). That means we have to use the blocks we do have to come up with new behavior similar to the blocks we don’t have. That’s what a “workaround” is—using what you’ve got to make something new and useful!
Then you should be able to search for blocks.
AndPherbCodes
Scratcher
100+ posts

Scratch Workaround Guide VII

Has anyone created a project that has all block workarounds?
WsDanzel
Scratcher
52 posts

Scratch Workaround Guide VII

AndPherbCodes wrote:

Has anyone created a project that has all block workarounds?
By process of elimination!!! Not me
hill_walker123
Scratcher
100+ posts

Scratch Workaround Guide VII

_nix wrote:

rotate around sprite:

Use the basic trigonometry blocks “sin” and “cos” to follow the path a circle would make around the target sprite. (You can get those by dragging out the “abs of” block at the bottom of Operators and changing its dropdown menu.)

define rotate (degrees) degrees around (sprite)
set [direction before custom block ran v] to (direction)
set [distance v] to (distance to (sprite))
point towards (sprite)
set x to (([x position v] of (sprite)) + ((distance :: variables) * ([sin v] of (((direction) + (180)) + (degrees)))
set y to (([y position v] of (sprite)) + ((distance :: variables) * ([cos v] of (((direction) + (180)) + (degrees)))
point in direction (direction before custom block ran)
turn cw (degrees) degrees // This helps the sprite look like it's following the circle.

This script uses geometry concepts to calculate where the sprite should end up. It works by calculating a circle whose center is exactly on the target sprite, and one of its points is where the running sprite is (so its radius is the distance from the running sprite to the target sprite). It uses that circle to calculate where the sprite would be if it followed an arc (of specified degrees) around the circle.

A lot of the blocks here have to do with converting between values that work for trigonometry math, and converting them back into the right values to put onto the actual screen.
  1. The “cos” and “sin” blocks expect a direction from 0 to 360 while Scratch's “direction” block goes from -180 to +180, so we add 180.
  2. “cos” and “sin” don't actually deal with distances at all, they just assume you're talking about a circle with radius 1, so we multiply the results by the distance between the running and target sprites to scale to the right radius.
  3. “cos” and “sin” also don't deal with position, they assume you're talking about a circle centered at (0, 0). So, we use normal addition blocks to translate (move) the point so it's relative to the target sprite.
(Note that this exact workaround will make jagged lines if you're drawing with pen blocks, since it moves in two steps. You can replace the “set x” and “set y” blocks with a single “go to x: y:” block and it'll work the same way.)


aw, I didn't help anymore

nix bent the space-time continuum to prevent my assistance, dang you nix! /j
_nix
Scratcher
1000+ posts

Scratch Workaround Guide VII

hill_walker123 wrote:

_nix wrote:

rotate around sprite: (snip)
aw, I didn't help anymore

nix bent the space-time continuum to prevent my assistance, dang you nix! /j
Sorry. Thank you in retrospect in advance.

Powered by DjangoBB