Use "not" instead of the exclamation mark in GDScript files

Also add String casts
This commit is contained in:
Aaron Franke
2021-06-28 23:30:05 -04:00
parent 7bfc57d1ae
commit 7e129db12e
30 changed files with 67 additions and 66 deletions

View File

@@ -92,7 +92,7 @@ func _initialize_collision_shapes():
for node in $Shapes.get_children():
var body = node as PhysicsBody2D
var shape = body.shape_owner_get_shape(0, 0)
shape.resource_name = node.name.substr("RigidBody".length())
shape.resource_name = String(node.name).substr("RigidBody".length())
_collision_shapes.push_back(shape)

View File

@@ -25,7 +25,7 @@ func _physics_process(_delta):
for node in $Shapes.get_children():
var body = node as PhysicsBody2D
var space_state = body.get_world_2d().direct_space_state
var body_name = body.name.substr("RigidBody".length())
var body_name = String(body.name).substr("RigidBody".length())
Log.print_log("* Testing: %s" % body_name)
@@ -45,7 +45,7 @@ func _physics_process(_delta):
res = _add_raycast(space_state, center, center + Vector2(0, 40))
Log.print_log("Raycast inside: %s" % ("HIT" if res else "NO HIT"))
if body.name.ends_with("ConcavePolygon"):
if String(body.name).ends_with("ConcavePolygon"):
# Raycast inside an internal face.
center.x += 20
res = _add_raycast(space_state, center, center + Vector2(0, 40))

View File

@@ -91,7 +91,7 @@ func _on_option_selected(option):
func _find_type_index(type_name):
for type_index in range(_object_templates.size()):
var type_node = _object_templates[type_index]
if type_node.name.find(type_name) > -1:
if String(type_node.name).find(type_name) > -1:
return type_index
Log.print_error("Invalid shape type: " + type_name)