+3 votes

I am making a game launcher program for my multiple games and just got to the part where I need to download the .zip file and extract it. It would be lovely it someone could get back to me on this, since I am fairly new at GDScript, and have tried multiple things, none of which have worked.

If at all possible, I would like to be also, one done extracting the .zip file, delete it.

Thanks in advance.

Godot version 3.2.3
in Engine by (234 points)

2 Answers

+1 vote
Best answer

You can download the file with an HTTPRequest node (code below) but as far as I know, you cannot extract archive files.

You can however load .pck files at runtime (godot's file format for storing the res:// filesystem at export.) You can choose what files you place in the PCK per export preset. This could be used to somehow load a small game, or you could download this and a .exe to launch the game separate (I do this for a similar project to yours.)

Download a file with HTTPRequest (put this code in a HTTPRequest's script):

func download(url : String, target : String):
    download_file = target # where to save the downloaded file
    request(url) # start the download

HTTPRequest has a signal that it emits when the download completes, you can use that to do something with the file, then delete it.

You can also delete files using the Directory class's remove(path) function

by (157 points)
selected by

Thank you very much. I had seen the download file but I did not want to touch it and break everything.

This helped very much and may have just saved my launcher!

Thank you SO much!

Thanks! At the beggining I was thinking this doesn't work but it was because I forgot writting the file name and the extension with the "/" in the path.

0 votes
by (2,063 points)
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 Frequently asked questions and 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 [email protected] with your username.