How to know if a label text is the same as a value of a var
Asked Answered
H

3

0

i'm making a keypad thing and i don't know how to check if the label text is the same as a value of a var. here's my code :

func _physics_process(delta):
if $Label3D1.text == "hi":
get_tree().quit()

i set the label text to hi, but the game wont quit.

Hydrometallurgy answered 15/2, 2024 at 14:23 Comment(0)
O
0

Hydrometallurgy Make sure that the case is matching and check if you haven't pressed enter when inputting the text into label because that would add an additional character (newline) at the end of label's text creating a string "hi\n" which is not equal to "hi".

Okie answered 15/2, 2024 at 16:41 Comment(0)
H
0

thanks for the answer, also is there any way to know the length of text in a label3d. i tried to search for it but i didnt get any answer. i want to know if the length of a label3d text is more than 4

Hydrometallurgy answered 16/2, 2024 at 1:43 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.