Discuss Scratch

A-MARIO-PLAYER
Scratcher
1000+ posts

[Solved]

i have solved the issue, keeping this for archival. thx

Hi, I need help with this script. This is a script for a project that allows advertising projects. It's supposed to show the name of each project. However, when I add any project, it just says Sandwhich[sic], which is one of the first projects I added to my list. How do I fix this? Server issue or project issue?



Project here: https://scratch.mit.edu/projects/1067783659/

Server code here:
import scratchattach as scratch3
from scratchattach import Encoding as scratchencoder
session = scratch3.login("A-MARIO-PLAYER", REDACTED)
conn = session.connect_cloud("1067783659")
events = scratch3.CloudEvents("1067783659")
import time
@events.event
def on_set(event): #Called when a cloud var is set
    if event.var == "requestid":
      try:
        project = session.connect_project(event.value)
        if project.moderation_status() == "notsafe":
          print("Project is NFE and thus cannot be added.")
          return
        print(f"---\n{project.title}\nby @{project.author}\nID {project.id}")
        print("Responding to request...")
        conn.set_var("response", scratchencoder.encode(f"{project.title}"))
        conn.set_var("response2", project.id)
        print("Added!")
      except:
        print("Failed to respond. Project is probably unshared?")
@events.event #Called when the event listener is ready
def on_ready():
   print("Event listener ready!")
events.start()

Last edited by A-MARIO-PLAYER (Sept. 14, 2024 16:11:36)

A-MARIO-PLAYER
Scratcher
1000+ posts

[Solved]

A few ATers have visited the project and entered random ids to test the thing.

The project names appear to be the intended value in the server logs, but in the project it just says Sandwhich.
There's probably something wrong with project code so I'll forward this to Help with Scripts.
cosmosaura
Scratch Team
1000+ posts

[Solved]

Glad you found an answer! Since this is resolved, I'll close it to help highlight the answer and prevent future responses. If you need it re-opened, though, you can report this and ask.

Powered by DjangoBB