0 votes

I need to compare the values I stored in labels. I "settext(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 ".gettext" 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!

asked Jun 7 in Engine by Suleymanov (55 points)

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?

1 Answer

0 votes
Best answer

Firstly, it is better to set text with .text = instead of set_text() see here: https://github.com/godotengine/godot/issues/39206 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).

answered Jun 7 by MaaaxiKing (291 points)

Highly appreciated, mate! Thank you!

I am glad that I could help ;D

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.