Przeglądaj źródła

Merge pull request #3353 from Calinou/fix-asset-builtin

Always use parentheses when calling `assert()` in GDScript
Rémi Verschelde 5 lat temu
rodzic
commit
8b6518ebb5

+ 2 - 2
getting_started/scripting/gdscript/gdscript_styleguide.rst

@@ -64,7 +64,7 @@ Here is a complete class example based on these guidelines:
             return
 
         var target_state = get_node(target_state_path)
-        assert target_state.is_composite == false
+        assert(target_state.is_composite == false)
 
         _state.exit()
         self._state = target_state
@@ -635,7 +635,7 @@ in that order.
             return
 
         var target_state = get_node(target_state_path)
-        assert target_state.is_composite == false
+        assert(target_state.is_composite == false)
 
         _state.exit()
         self._state = target_state

+ 5 - 5
getting_started/workflow/best_practices/godot_interfaces.rst

@@ -167,8 +167,8 @@ Nodes likewise have an alternative access point: the SceneTree.
             return
 
         # Fail and terminate.
-        # Compiled scripts in final binary do not include assert statements
-        assert prop.
+        # Note: Scripts run from a release export template don't run `assert` statements.
+        assert(prop, "'prop' wasn't initialized")
 
     # Use an autoload.
     # Dangerous for typical nodes, but useful for true singleton nodes
@@ -342,9 +342,9 @@ accesses:
       # If one does not wish to fail these checks without notifying users, one
       # can use an assert instead. These will trigger runtime errors
       # immediately if not true.
-      assert child.has("set_visible")
-      assert child.is_in_group("offer")
-      assert child is CanvasItem
+      assert(child.has("set_visible"))
+      assert(child.is_in_group("offer"))
+      assert(child is CanvasItem)
 
       # Can also use object labels to imply an interface, i.e. assume it implements certain methods.
       # There are two types, both of which only exist for Nodes: Names and Groups