Skip to content

Instantly share code, notes, and snippets.

@CosineP
Last active April 12, 2018 13:33
Show Gist options
  • Save CosineP/291472819a73d215e6e1f67ed829e698 to your computer and use it in GitHub Desktop.
Save CosineP/291472819a73d215e6e1f67ed829e698 to your computer and use it in GitHub Desktop.
Script for updating the game that demonstrates the windows-only HTTPRequest problem I'm having
extends HTTPRequest
func _ready():
connect("request_completed", self, "_request_completed")
# Check if we need an update
request("http://cosinegaming.com/static/vanagloria/version.json")
func _request_completed(result, response_code, headers, body):
if result != RESULT_SUCCESS:
print("ERROR: COULD NOT UPDATE. RESULT #" + str(result))
completed()
return
# Just checking if we need an update
var server = JSON.parse(body.get_string_from_utf8()).result
# 0.0.0 -> Update-shell application, needs more resources
if server.version == util.version and util.version != "0.0.0":
completed()
else:
# Update the game, irrelevant for this example
pass
func completed():
get_tree().change_scene("res://scenes/lobby.tscn")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment