GML Upload and Download Ini Files?

Meowanator

Member
My game has a level maker that saves as an ini file. I was wondering if it would be possible to be able to upload the file to a server and then be able to download it within game, similar to Super Mario Maker. I'm using GMS 1.4.9999 and I have no experience with things like this. It's okay if the file needs to be converted to a different file type.
 

Coded Games

Member
Yeah definitely. I personally have been working with AWS Lambda for my game a lot. This is a serverless platform that allows you to make backends that you only pay for while they are being used.

So here is the logic that I would do:
1. (Client) Load the ini file into a string using file_text_read functions.
2. (Client) Take that string and encode it to base 64 using base64_encode. (This step may be optional).
3. (Client) Send that string to your server using http_post_string, append some key to identify the player to the request. Done on client.
4. (Server/Lambda Function) When a string is received save the file somewhere (like AWS S3) with the player identifier as the file name. You don't need to decode the string.

When the client wants to receive an ini they would simply use http_get to a lambda function, pull the file from S3 and return the encoded string. Which will be decoded and saved back as an ini file on the client.

It sounds all fairly complicated but really this all can be setup in an hour or two. You will need to know a bit of another language (any of these: Python, Node.js, Java, Go) to setup things on AWS Lambda. My professor has good tutorials about AWS Lambda and S3 here: http://faculty.washington.edu/wlloyd/courses/tcss562/assignments.html

The benefit to using serverless platforms like AWS Lambda is that they automatically scale and you are only charged when the services are being used. No need to pay for a server being up all the time when no one is playing your game. Unless thousands of people are playing your game, hosting will be free!
 
Last edited:

Hypotakt

Member
@Coded Games interesting. Could I ask you a bit more about AWS Lambda? I found it on the main page, but stuff isn't clear at all. So my plan for a cooperative online mode in my game is a peer-to-peer connection between the
users. That makes it cheap for me, because no backend is needed. BUT I need a little online node for something like lobbys. My users should not type the IP and the port of their session into a textbox, they should find clickable
buttons in the lobby menu. This requires a bit of TCP/IP communication. Is something like this possible with AWS Lambda? Do you encounter any troubles with ping/connection time? And what is with the price? Can you tell my
how much the use for a little bit of code per user costs?

- cheers
 

Coded Games

Member
@Coded Games interesting. Could I ask you a bit more about AWS Lambda? I found it on the main page, but stuff isn't clear at all. So my plan for a cooperative online mode in my game is a peer-to-peer connection between the
users. That makes it cheap for me, because no backend is needed. BUT I need a little online node for something like lobbys. My users should not type the IP and the port of their session into a textbox, they should find clickable
buttons in the lobby menu. This requires a bit of TCP/IP communication. Is something like this possible with AWS Lambda? Do you encounter any troubles with ping/connection time? And what is with the price? Can you tell my
how much the use for a little bit of code per user costs?

- cheers
So first of all I should explain a little about how AWS Lambda works. It is a FaaS platform (Function-as-a-Service) so you write individual functions that are ran in sort of containers (dubbed function instances). These instances are created and destroyed as needed. After a function is called the instance will be destroyed after somewhere between 30-60 minutes. The specs of a function instance depend on how much memory you assign. The maximum being 3GBs of ram which will give you a 2.5GHz 2-core CPU and the memory can be scaled all the way down to 128 MBs where you will get a CPU that is roughly the performance of 1/10th of one core at 2.5 GHz. FaaS platforms also allow dynamic scaling. So if you all of the sudden get 1000 requests at once the platform will scale the number of function instances to handle the requests. You can have up to 1000 concurrent function instances. To interact with functions you must go through an API-Gateway which is just a REST HTTP endpoint. So I don't think you can establish persistent TCP/IP connections with a function instance. But this doesn't mean that you still cannot use Lambda for another part of your game or you could also do some modifications to get a lobby working on it. For example you could have a function that interacts with a database which is what represents your lobby. Then you would just have to make http requests to the function to update if the player is still available or not. I think this could work but maybe a more traditional server with AWS EC2 might be a better approach.

The price of AWS Lambda is based directly on the runtime of your function. You pay $0.0000166667 per GB-second of runtime. This is weird units but it makes sense. So if you pick your function to have 1GB of ram. $1 will get you about 16 hours of continual function runtime. This DOES NOT MEAN function instance uptime. If you call a function that runs for 100 ms in an hour. You are only billed for that 100 ms even though the function instance will be alive for longer than that.
 
Last edited:

Hypotakt

Member
Alright, I understand the concept. This seems like a good alternative to rent a super slow and limited VPS. Thanks for your detailed explanation!

I think REST HTTP would be fine for my project aswell. As you said, you can store data of the IP/PORT elsewhere and send the data per HTTP, so that's not a worry :) I will give it definitely a try!
 
Top