Discuss Scratch
- Discussion Forums
- » Bugs and Glitches
- » Variables Automatically Change Back After Being Changed
- ItchyCatIII
-
500+ posts
Variables Automatically Change Back After Being Changed
I've been testing a project that is supposed to be able to, using cloud data, save a value for a specific account. For example, say user A uses the project and saves a value. User A can then revisit the project at any time (before or after closing the tab), and re-access his saved value.
Now, obviously, this project requires some fairly long variables. I don't think I ever got above 100 digits, but the variables were long enough that they couldn't all fit on the screen.
I did make a ton of mistakes while making this that would cause my scripts to assign an incorrect value to the cloud data, and had to set it to nothing a lot. Most of the time, when I did this, it was fine. However, oftentimes, despite that there were no scripts running, when I clicked the block to set my cloud variable to 0 or to a blank, it would change for a split second, then go right back. I even tried activating the following script:
What would happen was, the variable (which I had showing the whole time) would constantly switch between a blank, and it's old value, even though no other scripts were running that should have been settings this variable. When I refreshed the page, I would see the cloud variable back at its original value, but I could set it to a blank without further problems. However, after editing for more than a few minutes, the glitch re-occurs.
It got even worse on my test account, when I tried to test the project. First of all, if I went into the editor, any cloud variable that I changed would revert, and I would get a message that since this is somebody else's project, any changes I made wouldn't be persistent. I always took that to mean that it would make the cloud variable into a local variable, basically, but maybe I misinterpreted that and this isn't a glitch. However, what is definitely a glitch is that, every time I ran a test, the data variable would change to pretty much what I wanted, then go right back to its old value. At first, I thought this was a scripting problem, but upon breaking down the script and running it piece by piece, I found that the variable was being set correctly and then reverting back.
I wanted to make a video of this issue or something, but every time I thought about it, it magically stopped happening, and then whenever I wasn't thinking about recording it, it would start up again. I can share the project, if that would help anybody, but it's working now and I don't want to touch anything, and I'm not sure it's necessary.
I also have faint memories of experiencing a similar glitch on earlier projects.
My browser / operating system: MacOS Macintosh X 10.12.4, Chrome 58.0.3029.81, Flash 25.0 (release 0)
Now, obviously, this project requires some fairly long variables. I don't think I ever got above 100 digits, but the variables were long enough that they couldn't all fit on the screen.
I did make a ton of mistakes while making this that would cause my scripts to assign an incorrect value to the cloud data, and had to set it to nothing a lot. Most of the time, when I did this, it was fine. However, oftentimes, despite that there were no scripts running, when I clicked the block to set my cloud variable to 0 or to a blank, it would change for a split second, then go right back. I even tried activating the following script:
What would happen was, the variable (which I had showing the whole time) would constantly switch between a blank, and it's old value, even though no other scripts were running that should have been settings this variable. When I refreshed the page, I would see the cloud variable back at its original value, but I could set it to a blank without further problems. However, after editing for more than a few minutes, the glitch re-occurs.
It got even worse on my test account, when I tried to test the project. First of all, if I went into the editor, any cloud variable that I changed would revert, and I would get a message that since this is somebody else's project, any changes I made wouldn't be persistent. I always took that to mean that it would make the cloud variable into a local variable, basically, but maybe I misinterpreted that and this isn't a glitch. However, what is definitely a glitch is that, every time I ran a test, the data variable would change to pretty much what I wanted, then go right back to its old value. At first, I thought this was a scripting problem, but upon breaking down the script and running it piece by piece, I found that the variable was being set correctly and then reverting back.
I wanted to make a video of this issue or something, but every time I thought about it, it magically stopped happening, and then whenever I wasn't thinking about recording it, it would start up again. I can share the project, if that would help anybody, but it's working now and I don't want to touch anything, and I'm not sure it's necessary.
I also have faint memories of experiencing a similar glitch on earlier projects.
My browser / operating system: MacOS Macintosh X 10.12.4, Chrome 58.0.3029.81, Flash 25.0 (release 0)
- duckboycool
-
1000+ posts
Variables Automatically Change Back After Being Changed
The Scratch cloud is currently on Fallback-only since people were spamming it, and essentially breaking it by making 30 changes a second. (As your script would) This will happen for anything that updates the cloud too quickly at the moment. Try using wait blocks to make it work.
- ItchyCatIII
-
500+ posts
Variables Automatically Change Back After Being Changed
The Scratch cloud is currently on Fallback-only since people were spamming it, and essentially breaking it by making 30 changes a second. (As your script would) This will happen for anything that updates the cloud too quickly at the moment. Try using wait blocks to make it work.
How quickly is too quickly? Other than my
script, which I only made because my variables were changing back, I didn't think I was changing the cloud all that often. There were no changes to the cloud anywhere within the decoding script (it only read the cloud variable), and only three instances in the saving script where the cloud was changed (everything was encoded with local variables and transferred to a cloud variable at the very end; the other two times were to let the system know that somebody was saving data and then once to let it know I was done). That was set to run without screen refresh, but still, I wouldn't think that's too much. Also, it did run correctly most of the time on my main account - it was just on my test account, or when I'd been on the project too long, that the variable glitch would happen.
Next time it happens, though, perhaps slowing it down would be a good idea. How much does it need to be delayed, though?
- TheLogFather
-
1000+ posts
Variables Automatically Change Back After Being Changed
This should help explain what's happening (and so how to avoid it): https://scratch.mit.edu/discuss/post/2559838/
You might also find this is worth reading: https://scratch.mit.edu/discuss/post/2513131/
(In particular, note section 2 where it says that cloudvars can occasionally not set correctly, even when the project is correctly connected to cloud.)
You might also find this is worth reading: https://scratch.mit.edu/discuss/post/2513131/
(In particular, note section 2 where it says that cloudvars can occasionally not set correctly, even when the project is correctly connected to cloud.)
Last edited by TheLogFather (May 2, 2017 07:44:11)
- ItchyCatIII
-
500+ posts
Variables Automatically Change Back After Being Changed
https://scratch.mit.edu/discuss/post/2559838/This should help explain what's happening (and so how to avoid it):
You might also find this is worth reading: https://scratch.mit.edu/discuss/post/2513131/
(In particular, note section 2 where it says that cloudvars can occasionally not set correctly, even when the project is correctly connected to cloud.)
Thanks! That explains pretty much everything that was happening
- Discussion Forums
- » Bugs and Glitches
-
» Variables Automatically Change Back After Being Changed