Discuss Scratch

Samueldora
Scratcher
100+ posts

Variables don't refresh

In this project

https://scratch.mit.edu/projects/86498104/

the variables TODO and BEST are no longer refreshed on the screen. They did before, they still do if I run the project under phosphorus, but not if I run the project directly. This is really annoying, because the user now doesn't see, if the project is still working. I use Internet Explorer. Any ideas, system settings, simple Workarounds? Does anyone have similar problems?
deck26
Scratcher
1000+ posts

Variables don't refresh

Have you tried other browsers? From a quick look it works in Firefox.
Samueldora
Scratcher
100+ posts

Variables don't refresh

Thank you for this information.

I tried Firefox (on an other Computer), but there I have more general problems running Scratch, maybe because of the safety settings.

Of course I don't want to tell everybody “Use Firefox or Phosporus, if you want to use my project”. It should work on any system or browser, especially if it just about something basic like refreshing a changing variable.

deck26
Scratcher
1000+ posts

Variables don't refresh

Samueldora wrote:

Thank you for this information.

I tried Firefox (on an other Computer), but there I have more general problems running Scratch, maybe because of the safety settings.

Of course I don't want to tell everybody “Use Firefox or Phosporus, if you want to use my project”. It should work on any system or browser, especially if it just about something basic like refreshing a changing variable.

I don't disagree but part of this process is establishing whether this is a bug or glitch with Scratch or a problem with your project. If it works in one browser but not another it is potentially worth reporting in the Bugs and Glitches forum.

One thing to check - is the variable changing but not showing or just not changing? You could check by writing it out to a list every few seconds - just a temporary test, not something to leave in once you've done that.

It can also be worth trying to strip the project back to just a few sprites and scripts which still show the problem - if possible. That just makes it easier to eliminate potential other causes.
Samueldora
Scratcher
100+ posts

Variables don't refresh

deck26 wrote:

One thing to check - is the variable changing but not showing or just not changing? You could check by writing it out to a list every few seconds - just a temporary test, not something to leave in once you've done that.

Good idea! I tried to write the values out to a list. When I run it with the list visible it works and displays the variable TODO itself as well. If I Keep the list hidden, TODO again doesn't display.

I tried to hide the TODO variable, run the project, then and show TODO again then, but this didn't help.

No solution yet, but some valuable Information.
deck26
Scratcher
1000+ posts

Variables don't refresh

Samueldora wrote:

deck26 wrote:

One thing to check - is the variable changing but not showing or just not changing? You could check by writing it out to a list every few seconds - just a temporary test, not something to leave in once you've done that.

Good idea! I tried to write the values out to a list. When I run it with the list visible it works and displays the variable TODO itself as well. If I Keep the list hidden, TODO again doesn't display.

I tried to hide the TODO variable, run the project, then and show TODO again then, but this didn't help.

No solution yet, but some valuable Information.
The first situation is just because Scratch is being slowed down by always having to update the list - any project that displays a list can suffer from this. The key question is whether the value is being changed but not shown on screen (I suspect this is the case) or just not being changed and by writing to a list (even hidden) will tell you that.
Samueldora
Scratcher
100+ posts

Variables don't refresh

In the above test I wrote the content of TODO into the list. The value is changed, as you expected, even if the list is not displayed, but the variable changes on the screen only if the list is shown at the same time.
deck26
Scratcher
1000+ posts

Variables don't refresh

Samueldora wrote:

In the above test I wrote the content of TODO into the list. The value is changed, as you expected, even if the list is not displayed, but the variable changes on the screen only if the list is shown at the same time.
My only other question is whether it does actually have the value it is showing for at least part of the time. For example, if the value is shown as 0 and it has the value 0 repeatedly in between other values, is it perhaps set to 0 for longer than the other values and that's why you see that. A bit like a sprite having multiple costumes but you only see the one that is showing for most of any period of time. Or if it changes in a custom block but is reset at the end each time you might not see the intermediate changes.

This is all just useful info to understand the problem better and give you a better idea whether it is worth reporting as a bug or glitch.

Not sure I can add more to this discussion beyond that.
Samueldora
Scratcher
100+ posts

Variables don't refresh

deck26 wrote:

My only other question is whether it does actually have the value it is showing for at least part of the time. For example, if the value is shown as 0 and it has the value 0 repeatedly in between other values, is it perhaps set to 0 for longer than the other values and that's why you see that.

It has to show a countdown of the remaining first moves in the actual position. So, none of the values is repeated. In reality, now it shows the highest value and changes to zero when the last possible move is through.

By the way, I tried it under Firefox and Edge now, the problem is the same. But with Phosphorus it works correctly.

Thank you for your contributions anyway.
DadOfMrLog
Scratcher
1000+ posts

Variables don't refresh

If the changes to the variable are happening during a non-refresh custom block then you won't see any updates.

Scratch used to have a non-refresh execution timeout of half a second, which (mostly) ensured that updates happened regularly.

However, a bug with the timer in the most recent version (v461) has broken this.

See here for more info about the issue (though it doesn't mention the var update issue specifically – that's just a consequence of it getting ‘stuck’ in non-refresh longer than it should…)
https://github.com/LLK/scratch-flash/pull/1398

I'd recommend you try to split up your non-refresh work into chunks of time that are less than a second. (But don't use the timer block to time when get out of non-refresh, since that block is broken in v461 – if you want to do it by time then use “days since 2000” instead.)

Here's hoping the devs finally get around to pushing the fix into the online player very soon (it's already been way too long, and many of my speed-test projects are broken because of it…)

Last edited by DadOfMrLog (Aug. 8, 2018 13:35:55)



Alternate account: TheLogFather –– HowTos and useful custom blocks (see studio). Examples below…


- String manipulation - - - X to power of Y - - - Clone point to clone - Detect New Scratcher - Speed tests studio -

Samueldora
Scratcher
100+ posts

Variables don't refresh

@DadOfMrLog

Thank you for your hints. The TODO variable is calculated only within blocks which do refresh. Its only purpose is user information. In the phosphorus player it still works. I tried some workarounds, but the only one which works (display the list with TODO updates) is too ugly for practical use. I think I'll wait for the fix in the online player.
DadOfMrLog
Scratcher
1000+ posts

Variables don't refresh

OK, the timer issue is somewhat more subtle than just non-refresh. It also applies if there are no changes to anything on-screen (since Scratch then runs everything at turbo speed).

Looking through your project, it seems there are only a handful of places that TODO gets used.

I would suggest you try adding “wait 0 secs” just after each one.

That forces Scratch to pause until the next refresh, so I think it should allow chance for the variable to update on-screen, hence working around this Scratch timer bug for now…

Last edited by DadOfMrLog (Aug. 8, 2018 17:02:32)



Alternate account: TheLogFather –– HowTos and useful custom blocks (see studio). Examples below…


- String manipulation - - - X to power of Y - - - Clone point to clone - Detect New Scratcher - Speed tests studio -

Samueldora
Scratcher
100+ posts

Variables don't refresh

DadOfMrLog wrote:

Looking through your project, it seems there are only a handful of places that TODO gets used.

I would suggest you try adding “wait 0 secs” just after each one.

That forces Scratch to pause until the next refresh, so I think it should allow chance for the variable to update on-screen, hence working around this Scratch timer bug for now…


This works! I just had to add it in one place in the BAUM-Sprite. Thank you very much!
fnafsher187
Scratcher
30 posts

Variables don't refresh

for some reason when I try to put a change variable in a forever loop, it counts up slower than it normally does. and i think it might ruin some of my best projects.
fnafsher187
Scratcher
30 posts

Variables don't refresh

It's really actually anything! movement size and also volume doesn't work any more

Powered by DjangoBB