Godot Version
4.5.1.stable
Question
Hello everyone! I’m kinda new, and English is not my mother language so, I apologize in advance for any issues this post might have.
I’m having some issues displaying the variable’s value on the dialogue line “extra_lines”.
I’m not sure exactly what I’m doing wrong, the variable gets printed correctly but when I print the coins variable.
But when I try to print the array it doesn’t work (an also doesn’t work when the character has those conditions to trigger the extra line”
var coins: String # I wanted to add the value score_label.text directly
# but I had to do it with _assign_coins due to
# the score_label.text sometimes being null
# this function is to decide which dialogue display based on coins
func _check_coins():
print("coins: %s" % coins)
if(int(coins) < 12):
lines_to_go = blocked_lines
elif(int(coins) > 12):
lines_to_go = extra_lines
else:
lines_to_go = enter_lines
# this assigns the score label text to the variable coins
func _assign_coins():
if score_label:
print(score_label.text)
coins = str(score_label.text)
print("assign: %s" % coins)
(...)
var extra_lines: Array[String] = [
"Scum! You need 12 coins to...",
"Hrm, actually I need: %s" % coins,
"Yeah, exactly that number.. HEY.",
"DON'T STARE AT ME LIKE THAT, SCUM.",
"You may pass"
]
(...)
# When interacting with the character
func _on_char_interact():
_assign_coins()
_check_coins()
print(coins)
print(extra_lines)
DialogManager.start_dialog(global_position, lines_to_go, speech_sound)
await DialogManager.dialog_finished
(...)
I tried converting it to int, but nothing seems to work, I’ll keep debugging in case It works out and I’ll update this post!
output:
1
assign: 1
coins: 1
[“Scum! You need 12 coins to…”, "Hrm, actually I need: ", “Yeah, exactly that number.. HEY.”, “DON'T STARE AT ME LIKE THAT, SCUM.”, “You may pass”]