Discuss Scratch

TheMobileGames
Scratcher
100+ posts

Currently, what is the easiest way to detect cloud variable change in Python?

Since cloud logs are down, are there any semi-easy methods using Python to detect when a value of from any cloud variable on a project is changed with minimal delay? I have heard web sockets may work but I haven’t seen anyone confirm it truly does. From what I have seen, there doesn’t seem to be any way at all on Scratchattach to use any get variable function or event without cloud logs; although setting variables seems to be fine. Everyone please also post or link some example Python code that still works and relates to this problem so I can examine it. Furthermore, if it is possible, with the same or different method, is there a way to see which player changed that variable, and if not, it’s okay, I’ll just do more work coding.
Maximouse
Scratcher
1000+ posts

Currently, what is the easiest way to detect cloud variable change in Python?

You probably don't need this now that cloud logs work, but scratchattach has a WsCloudEvents class. It's similar to CloudEvents but uses websockets instead of cloud logs. The constructor takes a CloudConnection as a second argument:
conn = session.connect_cloud(project_id)
events = scratchattach.WsCloudEvents(project_id, conn)
It doesn't tell you which user changed the variable.

Last edited by Maximouse (Jan. 19, 2024 08:28:07)

Powered by DjangoBB