P5.js tables saveTable

I’m trying to save my highscore when my player dies but instead of saving it to the file it got the info from. It creates a new file and send it download. Why is it doing that? & how can I get it to save the file to the high score file I made to store the scores.

2 Likes
2 Likes

That doesn’t explain why it downloads the file instead of saves the file to where the file is.

1 Like

Browsers don’t give us any permission to change anything on a user’s computer! :space_invader:

2 Likes

so basically you saying it will only download the file unlike processing where it saves the scores to the file where it first got the scores

1 Like

Correct! Browser client-side code is run inside a very restricted sandbox w/ lotsa restrictions on what it can do to a device. :robot:

If you have more storing requirements than a storeItem() can offer: :file_folder:
p5js.org/reference/#/p5/storeItem

You’re gonna need to contact a server-side code which can save your files remotely. :bulb:

2 Likes

I’m not trying to do anything that effects anything outside of my program

1 Like

It’d be really nice if we could at least save files into the same folder our client-side app is running. :running_man:

However, even restricting our file saving to the app’s folder isn’t allowed! :cry:

For all available “workaround” alternatives for storing, you can read this article below: :eyeglasses:

2 Likes

Well js is dumb now I should return to java the smarter language

1 Like

It’s not JS’ fault. Any other browser client-side language would have those same restrictions! :roll_eyes:

BtW, JS has a server-side version called Node.js which can save to disk: :star_struck:

2 Likes

if every language would have same trouble why did java do what I’m trying to do without problem?

1 Like

When Java used to run online as a browser plugin it had similar restrictions as well. :clown_face:

Any client-side apps targeting browsers, regardless the language they have been written in, will have those same storage restrictions! :grimacing:

1 Like

well i’m going back to a language smart enough to alter its own files

1 Like

Well, as I have already informed, you can also use JavaScript to alter local files.

But you’re gonna need to use its Node.js version, which is a server-side JS.

In general, any programming language can have free reign over its local file system as long as it’s running outside a sandbox.

A browser is a kind of sandbox btW:

2 Likes

Wouldn’t that file in the program be local so when I try saving the table shouldn’t it have saved to that file?

1 Like

Browsers allow us to load files located in the same folder (and its subfolders) as the current app.

But when we save a file, even when using the same name as an existing 1, we can place any type of content in it; even content which doesn’t match the file’s extension mime!

That’s why browsers don’t allow us to save files. Instead a browser pops up a save dialog window to the user, so the user has full control whether to allow the save or not.

Besides cookies and local storage, the only full-fledged option is sending a file to some server, so it’s saved there instead of the user’s local file system.

3 Likes

The smart thing for them to do is have everyone use a copy and whenever it saves it saves to the origanal

1 Like