From 395c25b1fbe51f42decf402f97e51eabcc8c0a77 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 18 Jun 2023 16:43:22 +0200 Subject: Godot v3 -> v4 --- Global.gd | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Global.gd') diff --git a/Global.gd b/Global.gd index 9f60d2c..d326cc6 100644 --- a/Global.gd +++ b/Global.gd @@ -23,8 +23,8 @@ var Level_Map = [] func _ready(): - Network.connect("game_started", self, "_on_Network_game_started") - Network.connect("game_ended", self, "_on_Network_game_ended") + Network.connect("game_started", Callable(self, "_on_Network_game_started")) + Network.connect("game_ended", Callable(self, "_on_Network_game_ended")) self.init() @@ -63,7 +63,7 @@ func get_instance_level(idx): var global_level = self.get_level(idx) var Level = load(global_level.meta.path) - var instance_level = Level.instance() + var instance_level = Level.instantiate() instance_level.idx = idx return instance_level @@ -77,23 +77,23 @@ func start_level(idx): func end_level(instance_level): var global_level = self.get_level(instance_level.idx) - var time = stepify(instance_level.timer, 0.01) + var time = snapped(instance_level.timer, 0.01) if (global_level.time == 0 or time < global_level.time): global_level.time = time global_level.cleared_by = Network.player for id in Network.players: rpc_id(id, "_update_level_map", instance_level.idx, global_level) - get_tree().change_scene("res://UI/LevelSelect.tscn") + get_tree().change_scene_to_file("res://UI/LevelSelect.tscn") self.check_win() func cancel_level(): - get_tree().change_scene("res://UI/LevelSelect.tscn") + get_tree().change_scene_to_file("res://UI/LevelSelect.tscn") -remote func _update_level_map(idx, global_level): +@rpc("any_peer") func _update_level_map(idx, global_level): self.Level_Map[idx] = global_level emit_signal("level_map_updated") @@ -103,7 +103,7 @@ func start_game(): func _on_Network_game_started(): - get_tree().change_scene("res://UI/CharacterSelect.tscn") + get_tree().change_scene_to_file("res://UI/CharacterSelect.tscn") func end_game(): @@ -111,7 +111,7 @@ func end_game(): func _on_Network_game_ended(): - get_tree().change_scene("res://UI/GameOver.tscn") + get_tree().change_scene_to_file("res://UI/GameOver.tscn") self.Level_Map = [] self.init() @@ -172,6 +172,6 @@ func check_win_timer(): func open_menu(): - var Menu = load("res://UI/Menu/Menu.tscn").instance() + var Menu = load("res://UI/Menu/Menu.tscn").instantiate() get_tree().paused = true get_tree().current_scene.add_child(Menu) -- cgit v1.2.3