Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update certain example code snippets to use the new syntax #9805

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ Here is the GDScript sample code:

func _ready():
print("Start debugging")
HilbertHotel.connect("occupy_room", self, "_print_occupy_room")
HilbertHotel.occupy_room.connect(_print_occupy_room)
var rid = HilbertHotel.create_bus()
OS.delay_msec(2000)
HilbertHotel.create_bus()
Expand Down
2 changes: 1 addition & 1 deletion tutorials/navigation/navigation_introduction_2d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ It uses the NavigationServer2D and a NavigationAgent2D for path movement.
navigation_agent.target_desired_distance = 4.0

# Make sure to not await during _ready.
call_deferred("actor_setup")
actor_setup.call_deferred()

func actor_setup():
# Wait for the first physics frame so the NavigationServer can sync.
Expand Down
2 changes: 1 addition & 1 deletion tutorials/navigation/navigation_introduction_3d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ It uses the NavigationServer3D and a NavigationAgent3D for path movement.
navigation_agent.target_desired_distance = 0.5

# Make sure to not await during _ready.
call_deferred("actor_setup")
actor_setup.call_deferred()

func actor_setup():
# Wait for the first physics frame so the NavigationServer can sync.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Afterwards the function waits for the next physics frame before continuing with
func _ready():
# Use call deferred to make sure the entire scene tree nodes are setup
# else await on 'physics_frame' in a _ready() might get stuck.
call_deferred("custom_setup")
custom_setup.call_deferred()

func custom_setup():

Expand Down
4 changes: 2 additions & 2 deletions tutorials/performance/thread_safe_apis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Interacting with the active scene tree is **NOT** thread-safe. Make sure to use
# Unsafe:
node.add_child(child_node)
# Safe:
node.call_deferred("add_child", child_node)
node.add_child.call_deferred(child_node)

However, creating scene chunks (nodes in tree arrangement) outside the active tree is fine. This way, parts of a scene can be built or instantiated in a thread, then added in the main thread:

Expand All @@ -39,7 +39,7 @@ However, creating scene chunks (nodes in tree arrangement) outside the active tr
var enemy_scene = load("res://enemy_scene.scn")
var enemy = enemy_scene.instantiate()
enemy.add_child(weapon) # Set a weapon.
world.call_deferred("add_child", enemy)
world.add_child.call_deferred(enemy)

Still, this is only really useful if you have **one** thread loading data.
Attempting to load or create scene chunks from multiple threads may work, but you risk
Expand Down
2 changes: 1 addition & 1 deletion tutorials/scripting/singletons_autoload.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ current scene and replace it with the requested one.
# The solution is to defer the load to a later time, when
# we can be sure that no code from the current scene is running:

call_deferred("_deferred_goto_scene", path)
_deferred_goto_scene.call_deferred(path)


func _deferred_goto_scene(path):
Expand Down