Discuss Scratch

CoolGuyBug
Scratcher
100+ posts

Collaborative Pixel Canvas

A long time ago, in a galaxy far, far away I shared a Collaborative Pixel Canvas project. It worked fine. Then Scratch 3.0 broke it, and nothing saves. What went wrong, and how do I fix it?


deck26
Scratcher
1000+ posts

Collaborative Pixel Canvas

If this was a while ago it may have been before Scratch limited cloud variables to 256 digits - at one time you could store 10240 digits per variable. This change happened before Scratch 3 - latter day Scratch 2 only allowed 128 digits per variable.
CoolGuyBug
Scratcher
100+ posts

Collaborative Pixel Canvas

deck26 wrote:

If this was a while ago it may have been before Scratch limited cloud variables to 256 digits - at one time you could store 10240 digits per variable. This change happened before Scratch 3 - latter day Scratch 2 only allowed 128 digits per variable.
Nope. Each variable is only 60 digits.


codeman1044
Scratcher
1000+ posts

Collaborative Pixel Canvas

I've seen a lot of cloud issues come up since 3.0 dropped, and the most common solution I've seen is to delete your cloud variables then rewrite it the same way. It's really annoying to do, but I think it's with the way that the cloud variables changed in 3.0, and their old code is obsolete.

This is my signature, which shows up every time I post and is automatic. To make a signature of your own, locate the “Change your signature” option in the bottom left of the Discussion Home.
I am nothing if not consistently inconsistent.
Snap! is a website that offers block coding like Scratch, but also offers the creation of your own blocks and writing JavaScript functions. The adventurous should consider checking it out!
Potentially useful tutorials and topic coverage
If you want to see a new tutorial added to this, feel free to leave a suggestion on my profile.
CoolGuyBug
Scratcher
100+ posts

Collaborative Pixel Canvas

codeman1044 wrote:

I've seen a lot of cloud issues come up since 3.0 dropped, and the most common solution I've seen is to delete your cloud variables then rewrite it the same way. It's really annoying to do, but I think it's with the way that the cloud variables changed in 3.0, and their old code is obsolete.
It still doesn't work. When I refresh the page, the cloud variables return to what they were when I last saved the project.


imfh
Scratcher
1000+ posts

Collaborative Pixel Canvas

I can see in the cloud log that it is changing two of the cloud variables, but it doesn't seem to read the changes when I reload the page. Additionally it seems that only variable 1 and 4 are being set. You might be reading/setting the variables too quickly, maybe add a delay? Scratch sometimes disconnects from the cloud server for acting too fast. You could try something like this to limit how fast they are read and changed:

when green flag clicked
wait (1) secs // Allow time for the variables to load
set [1 v] to (☁ 1)
wait (0.1) secs // Could probably use smaller/no delay
set [2 v] to (☁ 2)
wait (0.1) secs
set [3 v] to (☁ 3)
wait (0.1) secs
set [4 v] to (☁ 4)

define list to variables
...
set [update cloud v] to [1] // Replaces setting the cloud vars

when green flag clicked
forever
wait until <(update cloud) = [1]>
set [update cloud v] to [0]
set [☁ 1 v] to (1::variables)
wait (0.1) secs // Could probably use a smaller delay
set [☁ 2 v] to (2::variables)
wait (0.1) secs
set [☁ 2 v] to (2::variables)
wait (0.1) secs
set [☁ 4 v] to (4::variables)
wait (0.1) secs // Might not need this one
end

Scratch to Pygame converter: https://scratch.mit.edu/discuss/topic/600562/
CoolGuyBug
Scratcher
100+ posts

Collaborative Pixel Canvas

imfh wrote:

I can see in the cloud log that it is changing two of the cloud variables, but it doesn't seem to read the changes when I reload the page. Additionally it seems that only variable 1 and 4 are being set. You might be reading/setting the variables too quickly, maybe add a delay? Scratch sometimes disconnects from the cloud server for acting too fast. You could try something like this to limit how fast they are read and changed:
Thanks for the advice! I just tried that, but it still doesn't work.


imfh
Scratcher
1000+ posts

Collaborative Pixel Canvas

Looking at the cloud log, it is actually saving all the variables to the cloud now. However, it is still not reading the cloud correctly.

You could try using a loop to repeatedly attempt to read from the cloud until it succeeds. Make sure to have a large delay in it somewhere since it is possible that the server could disconnect without it. Once you get it working, you could adjust/remove the delay.

Make sure your new scratcher variable is in working order for this(deleted and replaced, set to 0 and 1) as this won't work right without it.

when green flag clicked
repeat until <(☁ new scratcher)=[1]>
wait (1) secs // Large delay to prevent the server from disconnecting with the repeated loop
set [1 v] to (☁ 1)
wait (0.1) secs
set [2 v] to (☁ 2)
wait (0.1) secs
set [3 v] to (☁ 3)
wait (0.1) secs
set [4 v] to (☁ 4)
end
...

Scratch to Pygame converter: https://scratch.mit.edu/discuss/topic/600562/
imfh
Scratcher
1000+ posts

Collaborative Pixel Canvas

Actually, try deleting and recreating the variables again. I just had a very similar bug in my cloud leaderboard project. The variables can be set but not read.

To test if this is the problem, first rename one or two of your variables, eg. ☁ 1_old. Next, create a new cloud variable with the original name. Replace the places where the old variable is used with the new one. Then save and refresh your project.

If the row stored by the replaced variable is correctly read, then you'll need to do this for all of the variables.

Scratch to Pygame converter: https://scratch.mit.edu/discuss/topic/600562/
CoolGuyBug
Scratcher
100+ posts

Collaborative Pixel Canvas

IT WORKS!! Thank you so much for your help!


Powered by DjangoBB