0 votes

I'm trying to implement a highscore mechanic for a HTML5 game that i'm trying to make and my question is pretty much as stated above.

Is it possible to use File.open to read/write to a file located on a HTML server using IP or domain adress, given you have server permissions?

something like:

file = File.new()

First i was thinking of using the SQLite module by khairul169 i found here.
But i'm having trouble compiling the HTML export templates and using SQL for a highscore mechanic sounds like a bit of a overkill.

Thank you for your help!

in Engine by (65 points)

1 Answer

+1 vote

The way you have written this will not work as a URL is not a path on the file system.

The closest way to implement what you want is to use an http service that have some storage, and use HTTPClient to communicate with it.

It is quite simple, and many cloud providers have a free tier that may be sufficient for your needs.

You write your own service or use an a "key-value" database. If you are afraid touching these subjects yourself, you can try a complete "key value" cloud service such as this one.

For example, you could request https://www.example.com/highscore/list to get the list of high scores and https://www.example.com/highscore/myname/193 to put a new high score in the list.

Notice though, that this makes your game hackable, as anybody could send these requests and set any high score for any player.

by (262 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.