Skip to content

Commit d3bf402

Browse files
committed
requests and debug messages
right now it only checks for the version name, will test if it works or not with a new empty release
1 parent 90896ed commit d3bf402

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

pigeon.gd

+24
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
11
extends HTTPRequest
2+
3+
@export var current_version:String = ""
4+
5+
const GAME_URL:String = "https://api.github.com/repos/Sparrowworks/Pigeon/releases/latest"
6+
7+
func _ready() -> void:
8+
var err:Error = request(GAME_URL)
9+
if err != OK:
10+
print("Failed to send request.")
11+
12+
func _on_request_completed(result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray) -> void:
13+
if result != 0:
14+
print("Operation failed with result: " + str(result))
15+
return
16+
17+
if response_code != 200:
18+
print("Request failed with response code: " + str(response_code))
19+
return
20+
21+
var latest_version:Dictionary = JSON.parse_string(body.get_string_from_utf8())
22+
if current_version != latest_version["name"]:
23+
print("Update Available! Downloading...")
24+
else:
25+
print("You are using the latest version.")

pigeon.tscn

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44

55
[node name="Pigeon" type="HTTPRequest"]
66
script = ExtResource("1_jowyp")
7+
current_version = "1.0.0"
8+
9+
[connection signal="request_completed" from="." to="." method="_on_request_completed"]

0 commit comments

Comments
 (0)