Godot Version
Godot 4.4
Question
I’m trying to use an “if” statement with “or” conjunctions to call lines of an array. However, when I print text with these conditions, the print statements overlap. When I separate each “or” into a different “if” statement, the code works fine.
Here is the code I am using:
func _on_button_pressed() -> void:
var entry = TEXTS.instantiate()
dialogue_entries.add_child(entry)
if _next_content_index >= CONTENTS.size():
print("The last line has already been added!")
return
if _next_content_index >= SPEAKERS.size():
print("The last line speaker has already spoken")
return
if _next_content_index == 2 or 3 or 5 or 9:
print("Speaker 2 Speaks")
entry.anchor_left = 200
if _next_content_index == 1 or 4 or 6 or 7 or 8:
print("Speaker 1 Speaks")
entry.anchor_left = 0
entry.set_content(SPEAKERS[_next_content_index], CONTENTS[_next_content_index])
_next_content_index += 1
Here is what the console looks like:
