Discuss Scratch

Knightbot63
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

caftingdead261 wrote:

CLOUD LOG ARE BACK THIS IS NOT A DRILL I REPEAT CLOUD LOGS ARE BACK THIS IS NOT A DRILL

wvzack wrote:

Good news everyone the logs just came back up
Awesome.

Working on an RPG. Consistently losing followers because of inactivity.
I head to forums time-to-time. Not as much as I used to.
mas6y6
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

THE CLOUD LOGS ARE BACK!!!!!!!@!

Hi i am mas6y6 i am the maker and owner for Scratch Cloud



Its a Scratch in Scratch Project

======
The Cloud Web has been discontinued
EpicCoderGamer1000
Scratcher
79 posts

scratchattach - A Scratch API wrapper (Python)

mas6y6 wrote:

THE CLOUD LOGS ARE BACK!!!!!!!@!
We know

epic coder gamer 1000
scaryghost14
Scratcher
53 posts

scratchattach - A Scratch API wrapper (Python)

EpicCoderGamer1000 wrote:

mas6y6 wrote:

THE CLOUD LOGS ARE BACK!!!!!!!@!
We know
yes back up!!!
when green flag clicked
if <cloud_logs = back up> then
say [yes!!]


else
sad
end

play https://scratch.mit.edu/projects/860188790/ it is fun follow scaryghost14
when I receive [I'm board v]
follow [scaryghost14]
ajskateboarder
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

8_bit_pixel wrote:

Just found this, seeing how to import to CodeSandbox.
I'm not able to run the Python CodeSandbox due to some strange error with a “microVM”, but my guess is that it probably should work if you create a terminal and run “pip install scratchattach”
perperperper
Scratcher
16 posts

scratchattach - A Scratch API wrapper (Python)

EpicCoderGamer1000 wrote:

mas6y6 wrote:

THE CLOUD LOGS ARE BACK!!!!!!!@!
We know
yep

well

























I'm a MEMER, and an ASAIN FURRY
grandpasp
Scratcher
39 posts

scratchattach - A Scratch API wrapper (Python)

I'm trying to add 2 projects to the Scratchattach studio. They keep disppearing!
ScratchcatandGobo
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

Wait they are back up- *GROWS MENTALLY INSTABLE*



























amoungus
Eason_9
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

I already installed scratchattach but it says I haven't. Can anyone help?

Picture here btw: https://u.cubeupload.com/eason_9_lol/Screenshot2024012015.png

(also cloud logs are up!!!! )

*This is my signature, it will appear below every post of mine! Scroll down by highlighting anywhere and press shift and the down arrow key.




EpicCoderGamer1000
Scratcher
79 posts

scratchattach - A Scratch API wrapper (Python)

Eason_9 wrote:

I already installed scratchattach but it says I haven't. Can anyone help?

Picture here btw: https://u.cubeupload.com/eason_9_lol/Screenshot2024012015.png

(also cloud logs are up!!!! )

What are you using to code

Also you don't need to use the cloud emoji to set a var

epic coder gamer 1000
TheMobileGames
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

Hey, does anyone know of some problems that I could have made that results in a lot of data being lost? I am currently using cloud events such as this and I’m wondering if it’s lossless when the project is full of people and busy (constant cloud variable changes):
import scratchattach as scratch3

events = scratch3.CloudEvents(“project_id”)

@events.event
def on_set(event): #Called when a cloud var is set
print(f“{event.user} set the variable {event.var} to the value {event.value} at {event.timestamp}”)

@events.event #Called when the event listener is ready
def on_ready():
print(“Event listener ready!”)

events.start()
Also, from a single account, how fast can these variables be set with Scratchattach? Is it possible to set all 10 of them at max speed (10 per second, I think) while being completely lossless?

Lastly, does anyone have any tips for me to indeed make these things (events and setting cloud variables) lossless (or almost/close to lossless) while keeping the same speed? I would much rather resolve this without editing my Scratch code itself please.

Last edited by TheMobileGames (Jan. 20, 2024 21:50:54)


—————————— —————————— —————————— —————————— ——————————
A way to make any game easily mobile (no remixing needed): https://scratch.mit.edu/discuss/topic/733837
My mobile engine (use to add buttons/controls to a game): https://scratch.mit.edu/projects/778848092/
—————————— —————————— —————————— —————————— ——————————
TimMcCool
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

TheMobileGames wrote:

Hey, does anyone know of some problems that I could have made that results in a lot of data being lost? I am currently using cloud events such as this and I’m wondering if it’s lossless when the project is full of people and busy (constant cloud variable changes):
import scratchattach as scratch3

events = scratch3.CloudEvents(“project_id”)

@events.event
def on_set(event): #Called when a cloud var is set
print(f“{event.user} set the variable {event.var} to the value {event.value} at {event.timestamp}”)

@events.event #Called when the event listener is ready
def on_ready():
print(“Event listener ready!”)

events.start()
Also, from a single account, how fast can these variables be set with Scratchattach? Is it possible to set all 10 of them at max speed (10 per second, I think) while being completely lossless?

Lastly, does anyone have any tips for me to indeed make these things (events and setting cloud variables) lossless (or almost/close to lossless) while keeping the same speed? I would much rather resolve this without editing my Scratch code itself please.
Cloud events should be lossless because they use the clouddata log to detect cloud activity.
Setting cloud variables is not garantueed to be lossless. You can reduce loss by reconnecting to the cloud regularly (close old connection and open new connection).
When setting cloud variables with scratchattach using a CloudConnection, there is a 0.1s cooldown between cloud variable sets. (You can only use the conn.set_var function 10 times per second.) However you can open multiple cloud connections to a project in order to set cloud variables more often (using only one session / one account):
import scratchattach as scratch3
session = scratch3.Session("sessionid", username="username")
conn1 = session.connect_cloud("projectid")
conn2 = session.connect_cloud("projectid")
conn1.set_var("var", "value") # Sets a cloud var using connection 1
conn2.set_var("var", "value") # Sets a cloud var using connection 2

Developer of scratchattach, the most popular Python Scratch API wrapper
TimMcCool
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

RandomPerson13764 wrote:

bro, remove the module. delete it now. people are hacking with it like crazy!
Just like every useful tool, scratchattach can be abused. However, deleting the library would harm Scratch's Python dev community while it wouldn't stop hackers at all: There are plenty of other libraries that support setting cloud variables (many of these existed before scratchattach). Hackers could just use one of these libraries instead.

Last edited by TimMcCool (Jan. 21, 2024 01:34:16)


Developer of scratchattach, the most popular Python Scratch API wrapper
Air_heads
Scratcher
92 posts

scratchattach - A Scratch API wrapper (Python)

wvzack wrote:

Air_heads wrote:

wvzack wrote:

Air_heads wrote:

wvzack wrote:

-ProXeeI wrote:

RandomPerson13764 wrote:

bro, remove the module. delete it now. people are hacking with it like crazy!
who ?
Check robot destructor people are abusing and I hope this won’t happen but I would not be surprised if the st gets rid of scratchattach projects

People can still do it without scratchattach -_-
True but it sure simplifies it and yes people use html and js but still the blame goes on scratch attach.

I still don’t get your argument as to why the blame should be on Scratchattach …
If the API is public, then anyone can utilize it, and if you’re talking about JavaScript, scratchattach is completely irrelevant as it is a python library.
The blame goes on scratch attach because it is known of and well people don’t know much more than the basic programming in scratch and they have no idea how everything else works. (Notevveryone of course)

ScratchConnect and other libraries use a seemingly similar syntax as ScratchAttach, so anyone who knows how to use ScratchAttach can use ScratchConnect instead. I'm not even going to bring up the fact that ANYONE can access the API with a simple post request as your contention is based on the idea that libraries make it simpler to use the API.
Air_heads
Scratcher
92 posts

scratchattach - A Scratch API wrapper (Python)

TimMcCool wrote:

RandomPerson13764 wrote:

bro, remove the module. delete it now. people are hacking with it like crazy!
Just like every useful tool, scratchattach can be abused. However, deleting the library would harm Scratch's Python dev community while it wouldn't stop hackers at all: There are plenty of other libraries that support setting cloud variables (many of these existed before scratchattach). Hackers could just use one of these libraries instead.
@wvzack @TimMcCool essentially encapsulated my contention here. Read this post for a better understanding of what I am trying to convey.

Last edited by Air_heads (Jan. 21, 2024 01:40:35)

scaryghost14
Scratcher
53 posts

scratchattach - A Scratch API wrapper (Python)

TimMcCool wrote:

RandomPerson13764 wrote:

bro, remove the module. delete it now. people are hacking with it like crazy!
Just like every useful tool, scratchattach can be abused. However, deleting the library would harm Scratch's Python dev community while it wouldn't stop hackers at all: There are plenty of other libraries that support setting cloud variables (many of these existed before scratchattach). Hackers could just use one of these libraries instead.
cool

play https://scratch.mit.edu/projects/860188790/ it is fun follow scaryghost14
when I receive [I'm board v]
follow [scaryghost14]
TheMobileGames
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

TimMcCool wrote:

Cloud events should be lossless because they use the clouddata log to detect cloud activity.
Setting cloud variables is not garantueed to be lossless. You can reduce loss by reconnecting to the cloud regularly (close old connection and open new connection).
When setting cloud variables with scratchattach using a CloudConnection, there is a 0.1s cooldown between cloud variable sets. (You can only use the conn.set_var function 10 times per second.) However you can open multiple cloud connections to a project in order to set cloud variables more often (using only one session / one account):
import scratchattach as scratch3
session = scratch3.Session("sessionid", username="username")
conn1 = session.connect_cloud("projectid")
conn2 = session.connect_cloud("projectid")
conn1.set_var("var", "value") # Sets a cloud var using connection 1
conn2.set_var("var", "value") # Sets a cloud var using connection 2
Okay, I now understand that cloud events should be lossless. Yet, I still have some questions about setting cloud variables, below is some simplified example code for you to quickly analyze. Let’s say whenever any cloud variable in the project is changed, Scratchattach will set it back to 0 to emulate fast changes.
import scratchattach as scratch3
session = scratch3.login("TheMobileGames", os.environ["PASSWORD"])
conn1 = session.connect_cloud("project_id")
events = scratch3.CloudEvents("project_id")
@events.event
def on_set(event):
    conn1.set_var("event.var", "0")
@events.event
def on_ready():
   print("Event listener ready!")
events.start()
How should I change this to be as lossless as possible when setting variables? Am I really supposed to make 10 connections and a function that takes in “event.var” and sets it to the last used connection? If there isn’t one already, there should be a function in Scratchattach that can “just” handle setting 5-10 cloud variables with each being changed 10 times a second. Maybe there could be one that opens as many connections as it needs and automatically closes them, all internally, so all someone has to do is use it and it works even when it’s setting a lot quickly.

—————————— —————————— —————————— —————————— ——————————
A way to make any game easily mobile (no remixing needed): https://scratch.mit.edu/discuss/topic/733837
My mobile engine (use to add buttons/controls to a game): https://scratch.mit.edu/projects/778848092/
—————————— —————————— —————————— —————————— ——————————
Eason_9
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

EpicCoderGamer1000 wrote:

(#2268)

Eason_9 wrote:

I already installed scratchattach but it says I haven't. Can anyone help?

Picture here btw: https://u.cubeupload.com/eason_9_lol/Screenshot2024012015.png

(also cloud logs are up!!!! )

What are you using to code

Also you don't need to use the cloud emoji to set a var
I used VS Code for coding and cmd for downloading

*This is my signature, it will appear below every post of mine! Scroll down by highlighting anywhere and press shift and the down arrow key.




chloe2ego
Scratcher
28 posts

scratchattach - A Scratch API wrapper (Python)

TimMcCool
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

TheMobileGames wrote:

…Am I really supposed to make 10 connections and a function that takes in “event.var” and sets it to the last used connection? If there isn’t one already, there should be a function in Scratchattach that can “just” handle setting 5-10 cloud variables with each being changed 10 times a second. Maybe there could be one that opens as many connections as it needs and automatically closes them, all internally, so all someone has to do is use it and it works even when it’s setting a lot quickly.

I think in the use case you described, the gain in speed wouldn't justify the effort to code something like that. Using multiple connections can be beneficial if you want to set multiple cloud variables simultaneously, because one cloud connection only allows you to perform a total of 10 cloud var sets per second.

TheMobileGames wrote:

If there isn’t one already, there should be a function in Scratchattach that can “just” handle setting 5-10 cloud variables with each being changed 10 times a second.
That's an interesting idea tho. This feature doesn't exist atm, but I might add something like this to scratchattach in the future

import scratchattach as scratch3
session = scratch3.login("TheMobileGames", os.environ["PASSWORD"])
conn1 = session.connect_cloud("project_id")
events = scratch3.CloudEvents("project_id")
@events.event
def on_set(event):
    conn1.set_var("event.var", "0")
@events.event
def on_ready():
   print("Event listener ready!")
events.start()
When coding something like this, beware that the on_set event will also be called when the cloud variable is set to 0 by the Python script. To prevent an infinite loop of on_set events caused by the Python script itself, add something like this to the on_set event:
    if str(event.value) != "0":
        ...

Last edited by TimMcCool (Jan. 21, 2024 02:22:20)


Developer of scratchattach, the most popular Python Scratch API wrapper

Powered by DjangoBB