How to have the game read from a Google spreadsheet file?

Zodaris

Member
I have an HTML5 game that I recently released. I've decided to also make a desktop version with more features. What I want to do, is set up a Google spreadsheet that has 2 variables. A true/false, and a URL. The true/false will be to tell the HTML5 version of the game if the desktop version is ready to go (and also activating a banner advertising it), and the URL will the the store page that the player will be linked to if they click the banner. It doesn't have to be a Google spreadsheet, but it has to link to something that I can set up for free and can handle being called all the time like this.

Is this the best way to handle this? How would I handle this or a better method? I can easily get the code figured out for what to do with the variables, it's just getting the variables that I need help with.

Basically I want be able to show a banner just by changing one word in a file and have every copy of my game on whatever website they each may be on to show the banner.

Thanks for your time!
 
E

elementbound

Guest
I'd suggest to abandon the spreadsheet and use something that GMS can easily load ( INI files, simple text files, JSON ) and put that on Dropbox or Google Drive. Really, any service that lets you publicly share files ( and modify them afterwards without changing the URL ).
 
S

Shzd_Azd

Guest
Yeah, @elementbound, is correct, using an .ini file to store values and (then putting them into an array if necessary) is the best option, then storing that anywhere where the URL wouldn't change; web server, cloud storage etc.
 

Zodaris

Member
Okay, so putting a .ini file on dropbox would be better then. That does sound like it would work better, thanks! How get the file from dropbox via the code?
 

FrostyCat

Redemption Seeker
I'd suggest to abandon the spreadsheet and use something that GMS can easily load ( INI files, simple text files, JSON ) and put that on Dropbox or Google Drive. Really, any service that lets you publicly share files ( and modify them afterwards without changing the URL ).
You forgot one thing: It has to be a service that will let you serve files as-is without in-browser previews or splash screens.

With Dropbox, you have to set the dl parameter in the share link to 1 to bypass the preview. With Google Drive, see this article. These work for now, but there's no telling when Dropbox and Google will change their mind in the name of "user friendliness".

The criteria for serving files to a computer program are much stricter than serving files to a human user.

Okay, so putting a .ini file on dropbox would be better then. That does sound like it would work better, thanks! How get the file from dropbox via the code?
Get the share link for the file, change its dl parameter to 1, then use http_get() or http_get_file() to download it.

In the long run, however, I still recommend that you get a real web hosting account and serve the files off there.
 

Zodaris

Member
Thanks guys! lots of good information here. Thanks for the example code @Alexx . It worked like a charm when I put it in and adjusted it for my game. But for some bizarre reason, when I set the export to HTML5, it doesn't seem to even try to pull the file. Everything I've done to check where the problem is seems to point to it just simply ignoring the "http_get_file" command. That makes no sense. I'm going to try out the "http_get" command to see if that gives any results.
 

FrostyCat

Redemption Seeker
If you intend on exporting to HTML5, Dropbox and Google Drive are both disqualified because they don't serve files with CORS headers. Browsers will actively block these requests. Get a real web host, then serve the game off the same origin as the files it intends to use.

Please, if you are going to be making HTML5 games, learn some basic rules on browser sandboxing and stop expecting it to be able to everything that native platforms can do.
 

Zodaris

Member
I see. I knew I was going to need to get a web host at some point, but I didn't realize how important it was for me to get it asap.

Considering the fact that I couldn't find any tutorials on how to best use the HTML5 export, I'm happy I managed to release a game (despite having to redo all the sound code to get that to work). So perhaps I'll just leave this game be and learn this sandboxing stuff in prep for my next web game.
 
Top