How to call Label text to compare values stored in them?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Suleymanov

I need to compare the values I stored in labels. I “set_text(str(minutes) +str(seconds) +str(milliseconds))” for CurrentLap label and LastLap label that works fine. But in order to set text for BestLap label, I need to compare the values already in LastLap and BestLap labels. Like, for “if LastLap < BestLap” - I tried “.get_text” and that returned an error, I tried “.text” and it doesn’t seem to work either. What is the correct way to compare the values stored in labels? Thank you for your help!

Also, how do you guys make the script part in comments appear in other colors? What signs should I use my script between for it to appear in red while commenting here?

Suleymanov | 2020-06-07 12:15

:bust_in_silhouette: Reply From: MaaaxiKing

Firstly, it is better to set text with .text = instead of set_text() see here: set_text() isn't suggested at Label · Issue #39206 · godotengine/godot · GitHub Do if int(LastLap.text) < int(BestLap.text): Do something Or if the text is float replace int with float and if it is mixed, replace int with float too because you can’t compare ints with floats.
To correctly mark code, you have to select the code and press the curly brackets icon over this text field or presss the hotkey for this (Ctrl+K).

Highly appreciated, mate! Thank you!

Suleymanov | 2020-06-07 13:01

I am glad that I could help ;D

MaaaxiKing | 2020-06-07 13:09