I am trying to display the value of the timer into a text object. What would be the code that needs to be entered into the Text: ______ to get the timer value ? The code that could be similar to GlobalVariableString(GlobalVariableName) which is entered to get the value of the global variable to be it displayed by the text object ?
But how do i do the same going through the options without typing anything when clicking the txt button after it ? Is it possible. Just curious to know.
Or is there sections in documentations that shows all such codes ?
I think it is a flaw of the editor.
You can try other action and copy the code from there.
For some reason the action that changes text has fewer functions in the editor.
But now i got the problem in using trunc with the new code. How do i make it display one decimal place like 3.1, 2.4.etc. ? Where should i enter the trunc (value) in this code with all the brackets being there ?
Thanks but that didnât make any difference. There was no error even with that white space before.
It worked earlier but it truncated all the decimal places and didnât even show one place. I think the trunc (value) needs to be entered as trunc (1) for one place like â3.1â get displayed, trunc (2) for two places like â3.15â to get display displayed.etc. which was what i was asked with the question earlier. But the problem was all those brackets making me confuse where to enter the trunc (value) into there.
Eventhough it works fine for most of the parts, it doesnât seem to retain it while displaying a whole number. For instance, when reaching 3.0 it displays 3, instead of displaying 4.0 it just displays 4. So it is not the equivalent of trunc which always retains the decimal places which is itâs direct action. The workaround with the round function is not a perfect replacement i think.
The problem that it causes is that the timer appears inconsistent, glitchy and not at all smooth when itâs running.
So the trunc function is impossible to use with a value in gdevelop ? I think it does work to zero decimal places when itâs typed in as code. So there is no way to place in a value there to be done with a simple single line of code instead of a workaround ? I think if trunc works to zero places fine, there might be a code to make it run with a value similar to trunc (2).
Wait a second⊠while taking a rest I noticed that my workaround will work only if the timer doesnât reach 10 seconds, because after that time, even integer numbers without floating point will have a length > 1
Instead checking if the string length is = 1, you can check if the string contains a dot â.â, with the function:
StrFind(YourTextObject.String(), ".")
If this function returns -1, the dot was not found so you have to add â.0â.
trunc just discards the decimal part of the number, and return the integer, but something like text formatting functions would be useful indeed
I am still getting confused when i try to implement more codes. I am attempting to reverse the timer to display a countdown but i am confused with the brackets and itâs doesnât seem to be working.
In my case, the timer needed to be only a single digit number so it didnât matter much. But itâs still a great improvement and i will try to implement it using the method.
So it just removes the decimal and gets the integer in godot. If thatâs the case, what i said wouldnât exist.