"And" Statements in "If" Conditions with Dialogic

Godot 4.4

I am trying to make an “If” condition with “and” statements to check if multiple conditions are met before continuing,

I have tried two coding blocks:

func _on_dialogic_signal(argument: String):
	if argument == "AchaemenidesInitialEnd" and "AdultInitialEnd":
		print("Achaemenides left the bus")

When I tried this code, only the first argument caused the print signal. The second argument was skipped over.

func _on_dialogic_signal(argument: String):
	if argument == "AchaemenidesInitialEnd" and argument == "AdultInitialEnd":
		print("Achaemenides left the bus")

With this code, neither signal triggers the print output.

I suspect it’s because the Dialogic plugin only takes one argument at a time. Is there a way to work around this?

if you want either to trigger the print you can use or instead of and.

func _on_dialogic_signal(argument: String):
	if argument == "AchaemenidesInitialEnd" or argument == "AdultInitialEnd":
		print("Achaemenides left the bus")

Your first attempt does not work because Godot doesn’t know you wanted to compare argument to "AdultInitialEnd", instead Godot thinks you are checking if the string "AdultInitialEnd" has contents (not empty) which it does have contents; effectively similar to this line which may be more illuminating as to why it logically doesn’t make sense

if argument == "AchaemenidesInitialEnd" and "AdultInitialEnd" != "":

I want both to be required to trigger the print.

I tried using the second block, and the same issue occurred. Should the != “” check the code for the condition, rather than the presence of contents?

I suppose you would have to track the arguments externally if you do need to and the arguments, but I’d hope your plugin has a better system for tracking progress/variables than a single argument signal, and seems like they do: Dialogic Variables

var adult_initial_end: bool = false
var achaemenides_initial_end: bool = false

func _on_dialogic_signal(argument: String):
	if argument == "AchaemenidesInitialEnd":
		achaemenides_initial_end = true
	elif argument == "AdultInitialEnd":
		adult_initial_end = true

	if adult_initial_end and achaemenides_initial_end:
		print("Achaemenides left the bus")

No I was trying to explain further why your initial snippet is wrong. These two lines are effectively the same, I hope it makes more sense why you wouldn’t want to do that.

if argument == "AchaemenidesInitialEnd" and "AdultInitialEnd":
# ^ same as this v
if argument == "AchaemenidesInitialEnd" and "AdultInitialEnd" != "":

That worked for me, thank you so much! Tracking variables makes a lot more sense now

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.