Discuss Scratch

Oakleaf30
Scratcher
2 posts

Writing variables to a file on raspberry pi 4

Hi all, I'm trying to find a way to save a variable to a file on my raspberry pi 4 such as a high score for a game for example. I've looked around but haven't found anything about doing such a thing so I don't know if it's even possible. Does anyone know if it is possible and if so how to do it?
yadayadayadagoodbye
Scratcher
1000+ posts

Writing variables to a file on raspberry pi 4

Couldn't you just manually type whatever is in the variable onto the file? Or are you trying to make it like, save your stats to your device? If the second, thats simply impossible as scratch does not have enough permissions to do that.

(You could try to look into turbowarp extensions tho, as Javascript might be able to save information to your device. I am, however, unfamiliar with that and cannot help in that regard)

Scratchers that I've cati-fied
ben_and_co
Scratcher
3 posts

Writing variables to a file on raspberry pi 4

i have a raspberry pi

thomasandbenji
Oakleaf30
Scratcher
2 posts

Writing variables to a file on raspberry pi 4

I see, yeah I'm trying to do the second for a project but if it's not possible I'll figure something else out. Thank you
BigNate469
Scratcher
1000+ posts

Writing variables to a file on raspberry pi 4

yadayadayadagoodbye wrote:

Couldn't you just manually type whatever is in the variable onto the file? Or are you trying to make it like, save your stats to your device? If the second, thats simply impossible as scratch does not have enough permissions to do that.

(You could try to look into turbowarp extensions tho, as Javascript might be able to save information to your device. I am, however, unfamiliar with that and cannot help in that regard)
JS can save things to your device, but it does so in the form of files, and it cannot directly edit files on your device for security reasons (even if you allowed it to; it's just not built into the File API)

You could try using the Pi as a server and accessing the Scratch API (api.scratch.mit.edu), and using that to access cloud variables in your project. Then, you just save what you want as a cloud variable.
Be warned, this requires quite a large amount of technical knowledge to make it work.

Highlight any part of this signature and press ctrl+shift+down arrow to see the rest of it.
For information on a signiture, including how to make one, visit here.
Please read the list of Officially Rejected Suggestions before posting a suggestion for Scratch!
View all of the topics you've posted in:
https://scratch.mit.edu/discuss/search/?action=show_user&show_as=topics
View all of your posts:
https://scratch.mit.edu/discuss/search/?action=show_user&show_as=posts
Lesser-known Scratch URLs:
https://scratch.mit.edu/projects/PROJECT ID HERE/remixtree (replace “PROJECT ID HERE” with project id number. Shows all the remixes of the project, and the remixes of those projects, and the remixes of those projects, and so on, as a chart. Link currently redirects to one of my projects). There was a button on the project page linking to this in 2.0, but it was removed.
View a larger list at: https://scratch.mit.edu/discuss/topic/542480/
Why @Paddle2See's responses are so often identical: https://scratch.mit.edu/discuss/topic/762351/
1000th post

The devs really need to update the scratch-gui repo- I'm getting at least 19 “npm warn deprecated” warnings whenever I try to install its dependencies, and yes, I'm using the latest version of node.js and npm. Then again, the dev page on this website and the wiki in the repo still refer to Scratch 3.0 in beta, and link the current website as an example of 2.0.

Powered by DjangoBB