Merge pull request #71461 from snoopdouglas/snoopdouglas/master

Class reference: snake_case .tscn & .gd filenames, _on_* callbacks
This commit is contained in:
Rémi Verschelde 2023-01-16 09:41:36 +01:00
commit f96701eda6
No known key found for this signature in database
GPG Key ID: C3336907360768E1
6 changed files with 9 additions and 9 deletions

View File

@ -14,7 +14,7 @@
func test(): func test():
var callable = Callable(self, "print_args") var callable = Callable(self, "print_args")
callable.call("hello", "world") # Prints "hello world ". callable.call("hello", "world") # Prints "hello world ".
callable.call(Vector2.UP, 42, callable) # Prints "(0, -1) 42 Node(Node.gd)::print_args". callable.call(Vector2.UP, 42, callable) # Prints "(0, -1) 42 Node(node.gd)::print_args".
callable.call("invalid") # Invalid call, should have at least 2 arguments. callable.call("invalid") # Invalid call, should have at least 2 arguments.
[/gdscript] [/gdscript]
[csharp] [csharp]

View File

@ -180,14 +180,14 @@
[codeblocks] [codeblocks]
[gdscript] [gdscript]
func _make_custom_tooltip(for_text): func _make_custom_tooltip(for_text):
var tooltip = preload("res://SomeTooltipScene.tscn").instantiate() var tooltip = preload("res://some_tooltip_scene.tscn").instantiate()
tooltip.get_node("Label").text = for_text tooltip.get_node("Label").text = for_text
return tooltip return tooltip
[/gdscript] [/gdscript]
[csharp] [csharp]
public override Godot.Control _MakeCustomTooltip(String forText) public override Godot.Control _MakeCustomTooltip(String forText)
{ {
Node tooltip = ResourceLoader.Load<PackedScene>("res://SomeTooltipScene.tscn").Instantiate(); Node tooltip = ResourceLoader.Load<PackedScene>("res://some_tooltip_scene.tscn").Instantiate();
tooltip.GetNode<Label>("Label").Text = forText; tooltip.GetNode<Label>("Label").Text = forText;
return tooltip; return tooltip;
} }

View File

@ -8,7 +8,7 @@
Below a small example of how to use it: Below a small example of how to use it:
[codeblocks] [codeblocks]
[gdscript] [gdscript]
# ServerNode.gd # server_node.gd
extends Node extends Node
var dtls := DTLSServer.new() var dtls := DTLSServer.new()
@ -86,7 +86,7 @@
[/codeblocks] [/codeblocks]
[codeblocks] [codeblocks]
[gdscript] [gdscript]
# ClientNode.gd # client_node.gd
extends Node extends Node
var dtls := PacketPeerDTLS.new() var dtls := PacketPeerDTLS.new()

View File

@ -17,7 +17,7 @@
func undo_something(): func undo_something():
pass # Put here the code that reverts what's done by "do_something()". pass # Put here the code that reverts what's done by "do_something()".
func _on_MyButton_pressed(): func _on_my_button_pressed():
var node = get_node("MyNode2D") var node = get_node("MyNode2D")
undo_redo.create_action("Move the node") undo_redo.create_action("Move the node")
undo_redo.add_do_method(self, "do_something") undo_redo.add_do_method(self, "do_something")

View File

@ -60,7 +60,7 @@
_can_shoot = false _can_shoot = false
_cool_down.start() _cool_down.start()
func _on_CoolDownTimer_timeout(): func _on_cool_down_timer_timeout():
_can_shoot = true _can_shoot = true
[/gdscript] [/gdscript]
[csharp] [csharp]

View File

@ -18,7 +18,7 @@
func _ready(): func _ready():
# We assume this node has a button as a child. # We assume this node has a button as a child.
# This button is for the user to consent to entering immersive VR mode. # This button is for the user to consent to entering immersive VR mode.
$Button.pressed.connect(self._on_Button_pressed) $Button.pressed.connect(self._on_button_pressed)
webxr_interface = XRServer.find_interface("WebXR") webxr_interface = XRServer.find_interface("WebXR")
if webxr_interface: if webxr_interface:
@ -38,7 +38,7 @@
if session_mode == 'immersive-vr': if session_mode == 'immersive-vr':
vr_supported = supported vr_supported = supported
func _on_Button_pressed(): func _on_button_pressed():
if not vr_supported: if not vr_supported:
OS.alert("Your browser doesn't support VR") OS.alert("Your browser doesn't support VR")
return return