Discuss Scratch
- purplepancake01
-
Scratcher
10 posts
When variable changes
I'd say semi, b/c I understand that you don't want to make a whole script for it, BUT, you can use a custom block for it.
forever
set (foo) to [something]
if <not <(foo) = [something]>> then (do something)
Last edited by purplepancake01 (June 25, 2022 22:46:32)
- carteradams123
-
Scratcher
49 posts
When variable changes
Late to the party, but full support. I'm creating a game where a “forever” loop cannot work in place of a “when variable changed?”
The specific scenario is to update a stamp when a certain variable changes. Other stamps need to be placed over it later, so using a forever loop to repeatedly update the bottom stamp cannot work as it would overwrite the other stamp layers. This creates a need to update the stamp only when necessary, which is each variable update.
The specific scenario is to update a stamp when a certain variable changes. Other stamps need to be placed over it later, so using a forever loop to repeatedly update the bottom stamp cannot work as it would overwrite the other stamp layers. This creates a need to update the stamp only when necessary, which is each variable update.
- imfh
-
Scratcher
1000+ posts
When variable changes
Late to the party, but full support. I'm creating a game where a “forever” loop cannot work in place of a “when variable changed?”Try using a second variable to keep track of the old value.
The specific scenario is to update a stamp when a certain variable changes. Other stamps need to be placed over it later, so using a forever loop to repeatedly update the bottom stamp cannot work as it would overwrite the other stamp layers. This creates a need to update the stamp only when necessary, which is each variable update.
forever
if <not <(variable)= (old variable)>> then
set [old variable v] to (variable)
stamp
end
end
Even better, send a broadcast whenever you change the variable. You could even make a custom block to update that specific variable.
- FishTC
-
Scratcher
26 posts
When variable changes
No support, easy workaround…I tried this, but didn't really find a sense button that detects variable changes.forever
if <doing something :: sensing> then
change [score v] by (1)
... :: grey
end
end
- -Valtren-
-
Scratcher
1000+ posts
When variable changes
One alternative could be making it so that whenever a variable is changed it updates something. A bit manual but if you're in control of when a variable changes then it should be good.No support, easy workaround…I tried this, but didn't really find a sense button that detects variable changes.forever
if <doing something :: sensing> then
change [score v] by (1)
... :: grey
end
end
Another workaround could be this:
define detectit's not perfect but it would detect if the variable changed.
set [oldvar v] to (my variable)
wait until <not <(oldvar) = (my variable)>>
- acohen_bhusd
-
Scratcher
500+ posts
When variable changes
the other topic with more posts was closed as it was a duplicate, post count does not matter
- Randomeder
-
Scratcher
2 posts
When variable changes
wait what discussion pages are still up?? its been a few years since I have been on scratch
- tagrim123
-
Scratcher
500+ posts
When variable changes
when [timer v] > ((timer) - <not<(old) = (targetvariable)>>)Until this is added, use this! BUMP
set [old v] to (var)
... // Do Something
Support!









