Discord
Login
Community
DARK THEME

How to save files locally with file.save( obj, name ) at the specific path?

I need to save scores from html5 game as json files at server that I'm hosting how can i do that because
system.file.save( obj, name ) just gives me download of that file?
while system.project API fits it is only used in studio so that makes it useless for this
Can I somehow export with that API?
Also i will need to load those files...
So I need save system of AAA games basically so i have save file...but on server alongside game ore separate dir

If you want to save the game state only for a given player locally, you can use:

  storage.set(key,value)

It will only work for the browser in which you launched the game. There is no need to send anything to the server.

If you have a server and you can run node.js code on it, you can use MicroScript2 network options. Details in the documentation - section >> advanced topics >> networking.

@Loginus Thanks for response but my server providers wouldn't let me use nodeJS and i need to store multiple scores
for later usage so it's not save score per client and i this fascinates me that you cannot export to filesystem how?why?

MicroScript has no functions that would allow any interaction with servers on the Internet.

You can make a GET/POST request to the server using code written in JavaScript. However, the server must wait for such a message and process it itself.

https://reqbin.com/code/javascript/wzp2hxwh/javascript-post-request-example

Here is an example of how to use JavaScript code with MicroScript2 code for web queries.

https://microstudio.io/i/Loginus/get3/

As Loginus says :)

Browser security restrictions won't allow to save files automatically, user interaction is required.

Along the lines of Loginus's example, here a test where I use a public highscore server:

https://microstudio.dev/i/TinkerSmith/leaderboard/

Thank you @Loginus and @TinkerSmith for useful help that's great solution.

I'm making leader-board API server in python for this now; I will share code when it's done :) While I still think this is lack of functionality it is understandable for web application/game to disallow
generating file or saving file on server for security reasons but when there is option to make executable for OS then that option is required now idk what will happen with exe export I didn't tried it.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community