#How do external files and saving work on web exports?

41 messages · Page 1 of 1 (latest)

dense lake
#

So in Godot the way you do this is by storing files in the game folder and then you can write/read to those files using some scripts. How does that work on web? Do you just do the same thing and godot will handle everything for you?

Also how do you save data on the web? The only way to do that is using cookies or external servers, since once you leave the web page everything gets reset and it isn't stored on your computer.

thick anvil
#

not sure what you mean by "game folder" but web browsers may allow web applications running in them to access the client filesystem. Of course, the degree of access is limited by system and browser configuration, e.g. Brave has some feature blocking access mentioned here https://godotengine.org/qa/102273/html5-whats-the-file-path-for-brave-browser

dense lake
thick anvil
dense lake
# thick anvil page or filesystem sub-tab?

I have this in mind.

But I mean, if I add external files reading and writing to my game, would I have to do any extra work for web exports or do I just not worry about it?

thick anvil
dense lake
#

But I mean, if I add external files reading and writing to my game, would I have to do any extra work for web exports or do I just not worry about it?

thick anvil
#

as I said you need to make sure that the client provides appropriate permissions

dense lake
#

so that's it?

thick anvil
#

what else?

dense lake
#

if I were to use the read/write file system like normal

#

then if I were to export it to HTML

#

it will work as expected?

thick anvil
#

Test it

prime ivy
#

It will work as expected, as long as you save files into user://

#

Just keep in mind the data is stored in indexeddb, which I believe is cleared if the user clears their browser cache

dense lake
prime ivy
#

It will behave like a file

#

Doesn't matter if you intend for it to be temporary, the engine will treat it the same

#

Also, the data is stored on your computer, and is not lost when you leave the page. It's only lost if the cache is cleared for the website

dense lake
prime ivy
#

Yes, but it's still stored in your hard drive

dense lake
#

(sorry, I don't know much about web)

prime ivy
#

I guess you can see it that way, but cookies are not the only system browsers have to save data

#

Technically it is not using cookies

dense lake
#

oh

#

so

#

does that mean

#

once you load up the website

#

the external files get loaded into your hard drive

#

which is where the scripts read/write from

#

(?)

prime ivy
#

When you load the website, the browser pulls the data from its cache, and that becomes available for Godot to read

dense lake
prime ivy
#

Yes, although I guess that's more of a browser implementation detail

#

You don't really need to worry about this though. Just know that if you read and write files to user://, it will work the way you would want when running on the web. The only extra thing you need to know is that it can be erased if the user erases their browser cache

dense lake
#

Okay thanks! Makes sense! Make sure to include "save data may be lost if you clear your browser cache!"

dense lake
#

@prime ivy Can I see where this data is stored? I used developer tools and it says there is no cache on the site