Discuss Scratch

jmb1293634
Scratcher
100+ posts

when variable changes

sorry if this was a duplicate I did check hard I checked the directory and 100 pages of the suggestions forum so here it is:
when [ v] changes::variables hat
so if the selected variable changes then it starts a script under it could also be:
[ v] changing?::variables boolean
cloverfly also suggested
wait until [ v] changes::variables stack
and
repeat until [ v] changes{

}::variables

Last edited by jmb1293634 (Jan. 20, 2025 17:23:18)

YtArie5
Scratcher
1000+ posts

when variable changes

A workaround DOES exist but it's a but annoying

wait until <not <(foo) = [something]>>
...
cloverfly
Scratcher
100+ posts

when variable changes

[variable v] changing?::variables boolean
seems rather ambiguous. would it be true on like, the frame the variable changes?
jmb1293634
Scratcher
100+ posts

when variable changes

cloverfly wrote:

[variable v] changing?::variables boolean
seems rather ambiguous. would it be true on like, the frame the variable changes?
yes but generally the hat is better so if I had the choice I would use that
jmb1293634
Scratcher
100+ posts

when variable changes

Bump
u
m
p
jmb1293634
Scratcher
100+ posts

when variable changes

bump
u
m
p
jmb1293634
Scratcher
100+ posts

when variable changes

bump
uu
m m
p p
cloverfly
Scratcher
100+ posts

when variable changes

when [variable v] changes::variables hat
is cool
I think it should be events:
when [variable v] changes::events hat

there should also be
wait until (variable v) changes :: control
and
repeat until (variable v) changes {
} :: control
jmb1293634
Scratcher
100+ posts

when variable changes

cloverfly wrote:

when [variable v] changes::variables hat
is cool
I think it should be events:
when [variable v] changes::events hat

there should also be
wait until (variable v) changes :: control
and
repeat until (variable v) changes {
} :: control
added to main suggestion
greenrid
Scratcher
40 posts

when variable changes

I support!
However, the

<[variable v] changing?::variables>

Boolean block could be turned into this to make a little more sense:

<When [variable v] changes::variables>

This way, it would be easier to tell what it means!
cake__5
Scratcher
100+ posts

when variable changes

here is the workaround
set [temp v] to (a)
wait until <not <(temp) = (a)>>
your code here::#0000ff
BigNate469
Scratcher
1000+ posts

when variable changes

cake__5 wrote:

here is the workaround
set [temp v] to (a)
wait until <not <(temp) = (a)>>
your code here::#0000ff
But that hangs the thread (prevents code later on from executing until the variable changes).

A better workaround would be:
forever
if <not<(previous value) = (variable)>> then
broadcast [variable has changed v]
end
set [previous value v] to (variable)
... // other code
end
when I receive [variable has changed v]
... // code for when variable changes here
Or, alternatively:
when [timer v] > ((timer) + <not <(previous value) = (variable)>>)
set [previous value v] to (variable)
... // code for when variable changes here

Last edited by BigNate469 (Jan. 21, 2025 15:18:57)

jmb1293634
Scratcher
100+ posts

when variable changes

bumpbumpbump
jmb1293634
Scratcher
100+ posts

when variable changes

bumpbumpbump
jmb1293634
Scratcher
100+ posts

when variable changes

bumpbumpbump
bump
bump
TheGreatestGoofy
Scratcher
27 posts

when variable changes

nice, but mentioned above, there are workarounds




buhmppp

Last edited by TheGreatestGoofy (Jan. 24, 2025 19:04:45)

jmb1293634
Scratcher
100+ posts

when variable changes

bump
seriouslyscratchy1
Scratcher
100+ posts

when variable changes

Support! High five!
AHypnoman
Scratcher
1000+ posts

when variable changes

seriouslyscratchy1 wrote:

Support! High five!
Please tell us why you support - asserting support, or lack-thereof, doesn't contribute to the discussion - the forums are not for polling.
jmb1293634
Scratcher
100+ posts

when variable changes

Powered by DjangoBB