Update game within the client.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By EnrikeChurin

Does godot allow any way of updating the game directly from file or server? Or maybe adding/replacing code, assets or other files of the project with code? It will allow to not rely on game stores and allow to not download whole game, but only parts that player wants to play.

:bust_in_silhouette: Reply From: TimiT

Yes, it can, but not all code. You should write loader manually :slight_smile:

Load file to user:// dir:

var file = File.new()
file.open("user://_path/to/file_", File.WRITE)
file.store_line(your_scene_file)
file.close()

Load scene dynamicully:

var scene = load("user://_path_to_scene_).instance()

Add script to node:

node.script.source_code="extends Reference\nfunc hw():\n\tprint(\"Hello World\")\n"
node.script.reload(true)
node.hw() # prints Hello World

Get files in directory:

var dir = Directory.new()
if dir.open(path) == OK:
    dir.list_dir_begin()
    var file_name = dir.get_next()
    while file_name != "":
        print("Found file: " + file_name)
        file_name = dir.get_next()

For example, you can load level10 scene file with imported script and save it in user://levels. Then check all files here and load required

Also you can use ResourceServer for this manipulations (but I’m not sshure)


Read more here:

:bust_in_silhouette: Reply From: Calinou

Implementing support for game updates is a much more complicated task than it sounds like at first. You have to use a secondary process since the main executable can’t be replaced while the project is running on Windows. Security is also important to keep in mind; you’re expected to sign releases so that malicious releases can’t be installed on clients if your server is compromised.

In short, it’s not really worth the effort compared to using a game store platform.

:bust_in_silhouette: Reply From: EnrikeChurin

I found the answer by myself. You can use .pck files to import additional contents to the game. This docs page has all the information. Also I found another Q&A posted in 2016 which had very similar question as this. Here is the link. Using this method should be pretty simple and should work better than TimiT had shown, because I think it should have code compiled to bytecode and have no limitation to what content can be added (except limit of max size of .pck file, it’s 2gb, but it may be solvable with a couple of .pck files instead of only one).