diff --git a/scenes/dragon_editor/dragon_editor.gd b/scenes/dragon_editor/dragon_editor.gd index f763fe9..64d111f 100644 --- a/scenes/dragon_editor/dragon_editor.gd +++ b/scenes/dragon_editor/dragon_editor.gd @@ -54,7 +54,13 @@ func _on_change_shoes_pressed() -> void: func _on_create_pressed() -> void: if dragon_name.text.is_empty(): return - on_create_dragon.emit(hat.texture, shirt.texture, shoes.texture, dragon_name.text) + + var hat_index: int = hat_outfits.get_index(hat.texture) + var shirt_index: int = shirt_outfits.get_index(shirt.texture) + var decor_index: int = shoes_outfits.get_index(shoes.texture) + var color_index: int = dragon_colors.get_index(dragon.texture) + var properties = DragonProperties.new(dragon_name.text, "tower", color_index, hat_index, shirt_index, decor_index) + on_create_dragon.emit(properties) queue_free() diff --git a/scenes/dragon_sharing.gd b/scenes/dragon_sharing.gd index ec4e025..a3052df 100644 --- a/scenes/dragon_sharing.gd +++ b/scenes/dragon_sharing.gd @@ -9,7 +9,7 @@ func _ready() -> void: request_completed.connect(_on_request_completed) -func _on_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray): +func _on_request_completed(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray): if response_code != 200: print("HTTP request returned error: ", response_code) return @@ -20,15 +20,15 @@ func _on_request_completed(result: int, response_code: int, headers: PackedStrin on_dragon_received.emit(properties) -func send(origin: String, name: String, color: int, shirt: int, hat: int, decor: int) -> void: - var url: String = 'http://torreta.gerardgascon.com/add/%s/%s/%s/%s/%s/%s/' % [origin, name, color, shirt, hat, decor] - var err = request(url) +func send(properties: DragonProperties) -> void: + var url: String = 'http://torreta.gerardgascon.com/add/%s/%s/%s/%s/%s/%s/' % [properties.origin, properties.name, properties.color, properties.shirt, properties.hat, properties.decor] + var err: int = request(url) if err != OK: print("HTTP request failed: ", err) func receive(origin: String) -> void: var url: String = 'http://torreta.gerardgascon.com/get/%s/' % origin - var err = request(url) + var err: int = request(url) if err != OK: print("HTTP request failed: ", err) diff --git a/scenes/main.gd b/scenes/main.gd index 631e974..8803ea9 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -92,6 +92,7 @@ func move_window_to_bottom_right(): func add_dragon(properties: DragonProperties): var id: int = _library.add_dragon(properties) + dragon_sharing.send(properties) for spot in dragon_spots: if not _filled_spots.has(spot): _instantiate_dragon_ingame(spot.position, properties)